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 / unsync2.t
CommitLineData
d9bb3666
MB
1use Thread;
2
3$| = 1;
4
5srand($$^$^T);
6
7sub 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
19sub 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
29new Thread (\&start_thread, "A");
30new 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
36print "main: exiting\n";