diff options
Diffstat (limited to 'contrib/perl5/ext/Thread/specific.t')
-rw-r--r-- | contrib/perl5/ext/Thread/specific.t | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/contrib/perl5/ext/Thread/specific.t b/contrib/perl5/ext/Thread/specific.t new file mode 100644 index 000000000000..da130b1d64c7 --- /dev/null +++ b/contrib/perl5/ext/Thread/specific.t @@ -0,0 +1,17 @@ +use Thread; + +use Thread::Specific qw(foo); + +sub count { + my $tid = Thread->self->tid; + my Thread::Specific $tsd = Thread::Specific::data; + for (my $i = 0; $i < 5; $i++) { + $tsd->{foo} = $i; + print "thread $tid count: $tsd->{foo}\n"; + select(undef, undef, undef, rand(2)); + } +}; + +for(my $t = 0; $t < 5; $t++) { + new Thread \&count; +} |