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 / lock.t
CommitLineData
734689b1
MB
1use Thread;
2
3$level = 0;
4
5sub worker
6{
7 my $num = shift;
8 my $i;
9 print "thread $num starting\n";
10 for ($i = 1; $i <= 20; $i++) {
11 print "thread $num iteration $i\n";
12 select(undef, undef, undef, rand(10)/100);
13 {
783070da 14 lock($lock);
734689b1
MB
15 warn "thread $num saw non-zero level = $level\n" if $level;
16 $level++;
17 print "thread $num has lock\n";
18 select(undef, undef, undef, rand(10)/100);
19 $level--;
20 }
21 print "thread $num released lock\n";
22 }
23}
24
25for ($t = 1; $t <= 5; $t++) {
26 new Thread \&worker, $t;
27}