Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / perl5 / ext / Thread / unsync2.t
1 use Thread;
2
3 $| = 1;
4
5 srand($$^$^T);
6
7 sub printargs {
8     my $thread = shift;
9     my $arg;
10     my $i;
11     while ($arg = shift) {
12         my $delay = int(rand(500));
13         $i++;
14         print "$thread arg $i is $arg\n";
15         1 while $delay--;
16     }
17 }
18
19 sub start_thread {
20     my $thread = shift;
21     my $count = 10;
22     while ($count--) {
23         my(@args) = ($thread) x int(rand(10));
24         print "$thread $count calling printargs @args\n";
25         printargs($thread, @args);
26     }
27 }
28
29 new Thread (\&start_thread, "A");
30 new Thread (\&start_thread, "B");
31 #new Thread (\&start_thread, "C");
32 #new Thread (\&start_thread, "D");
33 #new Thread (\&start_thread, "E");
34 #new Thread (\&start_thread, "F");
35
36 print "main: exiting\n";