This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add socklen_t probe; Configure maintenance.
[perl5.git] / ext / Thread / list.t
CommitLineData
0a00ffdb
MB
1use Thread qw(async);
2use Thread::Semaphore;
3
4my $sem = Thread::Semaphore->new(0);
5
6$nthreads = 4;
7
8for (my $i = 0; $i < $nthreads; $i++) {
9 async {
10 my $tid = Thread->self->tid;
11 print "thread $tid started...\n";
12 $sem->down;
13 print "thread $tid finishing\n";
14 };
15}
16
17print "main: started $nthreads threads\n";
18sleep 2;
19
20my @list = Thread->list;
21printf "main: Thread->list returned %d threads\n", scalar(@list);
22
23foreach my $t (@list) {
24 print "inspecting thread $t...\n";
25 print "...deref is $$t\n";
26 print "...flags = ", $t->flags, "\n";
27 print "...tid = ", $t->tid, "\n";
28}
29print "main thread telling workers to finish off...\n";
30$sem->up($nthreads);