diff options
author | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-16 16:42:13 +0000 |
---|---|---|
committer | Malcolm Beattie <mbeattie@sable.ox.ac.uk> | 1997-10-16 16:42:13 +0000 |
commit | c1f329308b702519079b58d1f4c523ce60dc9990 (patch) | |
tree | 055f535c918fdf314c15c62968c32da6b1cf1ac7 /ext/Thread/lock.t | |
parent | 8023c3ceb7a7110c55b3159dff471253f72f7e15 (diff) | |
parent | 0a00ffdb1e70eb883974513d0ee6f4afd54aca19 (diff) | |
download | perl-c1f329308b702519079b58d1f4c523ce60dc9990.tar.gz |
Move perlext/Thread into perl/ext/Thread.
p4raw-id: //depot/perl@141
Diffstat (limited to 'ext/Thread/lock.t')
-rw-r--r-- | ext/Thread/lock.t | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ext/Thread/lock.t b/ext/Thread/lock.t new file mode 100644 index 0000000000..fefb129879 --- /dev/null +++ b/ext/Thread/lock.t @@ -0,0 +1,27 @@ +use Thread; + +$level = 0; + +sub worker +{ + my $num = shift; + my $i; + print "thread $num starting\n"; + for ($i = 1; $i <= 20; $i++) { + print "thread $num iteration $i\n"; + select(undef, undef, undef, rand(10)/100); + { + lock($lock); + warn "thread $num saw non-zero level = $level\n" if $level; + $level++; + print "thread $num has lock\n"; + select(undef, undef, undef, rand(10)/100); + $level--; + } + print "thread $num released lock\n"; + } +} + +for ($t = 1; $t <= 5; $t++) { + new Thread \&worker, $t; +} |