From ff6b7ba98e8d4aab04cbe2bfdffdfc9171c1812b Mon Sep 17 00:00:00 2001 From: Mark Murray Date: Wed, 9 Sep 1998 07:00:04 +0000 Subject: Initial import of Perl5. The king is dead; long live the king! --- contrib/perl5/ext/Thread/list.t | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 contrib/perl5/ext/Thread/list.t (limited to 'contrib/perl5/ext/Thread/list.t') diff --git a/contrib/perl5/ext/Thread/list.t b/contrib/perl5/ext/Thread/list.t new file mode 100644 index 000000000000..f13f4b266a4c --- /dev/null +++ b/contrib/perl5/ext/Thread/list.t @@ -0,0 +1,30 @@ +use Thread qw(async); +use Thread::Semaphore; + +my $sem = Thread::Semaphore->new(0); + +$nthreads = 4; + +for (my $i = 0; $i < $nthreads; $i++) { + async { + my $tid = Thread->self->tid; + print "thread $tid started...\n"; + $sem->down; + print "thread $tid finishing\n"; + }; +} + +print "main: started $nthreads threads\n"; +sleep 2; + +my @list = Thread->list; +printf "main: Thread->list returned %d threads\n", scalar(@list); + +foreach my $t (@list) { + print "inspecting thread $t...\n"; + print "...deref is $$t\n"; + print "...flags = ", $t->flags, "\n"; + print "...tid = ", $t->tid, "\n"; +} +print "main thread telling workers to finish off...\n"; +$sem->up($nthreads); -- cgit v1.2.3