source: trunk/essentials/dev-lang/perl/ext/Thread/list.tx

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 797 bytes
Line 
1BEGIN {
2 eval { require Config; import Config };
3 if ($@) {
4 print "1..0 # Skip: no Config\n";
5 exit(0);
6 }
7}
8
9use Thread qw(async);
10use Thread::Semaphore;
11
12my $sem = Thread::Semaphore->new(0);
13
14$nthreads = 4;
15
16for (my $i = 0; $i < $nthreads; $i++) {
17 async {
18 my $tid = Thread->self->tid;
19 print "thread $tid started...\n";
20 $sem->down;
21 print "thread $tid finishing\n";
22 };
23}
24
25print "main: started $nthreads threads\n";
26sleep 2;
27
28my @list = Thread->list;
29printf "main: Thread->list returned %d threads\n", scalar(@list);
30
31foreach my $t (@list) {
32 print "inspecting thread $t...\n";
33 print "...deref is $$t\n";
34 print "...flags = ", $t->flags, "\n";
35 print "...tid = ", $t->tid, "\n";
36}
37print "main thread telling workers to finish off...\n";
38$sem->up($nthreads);
Note: See TracBrowser for help on using the repository browser.