Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / perl5 / ext / Thread / specific.t
1 use Thread;
2
3 use Thread::Specific qw(foo);
4
5 sub count {
6     my $tid = Thread->self->tid;
7     my Thread::Specific $tsd = Thread::Specific::data;
8     for (my $i = 0; $i < 5; $i++) {
9         $tsd->{foo} = $i;
10         print "thread $tid count: $tsd->{foo}\n";
11         select(undef, undef, undef, rand(2));
12     }
13 };
14
15 for(my $t = 0; $t < 5; $t++) {
16     new Thread \&count;
17 }