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 / unsync4.t
CommitLineData
d9bb3666
MB
1use Thread;
2
3$| = 1;
4
5srand($$^$^T);
6
7sub printargs {
8 my(@copyargs) = @_;
9 my $thread = shift @copyargs;
10 my $arg;
11 my $i;
12 while ($arg = shift @copyargs) {
13 my $delay = int(rand(500));
14 $i++;
15 print "$thread arg $i is $arg\n";
16 1 while $delay--;
17 }
18}
19
20sub start_thread {
21 my(@threadargs) = @_;
22 my $thread = $threadargs[0];
23 my $count = 10;
24 while ($count--) {
25 my(@args) = ($thread) x int(rand(10));
26 print "$thread $count calling printargs @args\n";
27 printargs($thread, @args);
28 }
29}
30
31new Thread (\&start_thread, "A");
32new Thread (\&start_thread, "B");
33new Thread (\&start_thread, "C");
34new Thread (\&start_thread, "D");
35new Thread (\&start_thread, "E");
36new Thread (\&start_thread, "F");
37
38print "main: exiting\n";