Retract #11165 since Sarathy pointed out it'll not
[p5sagit/p5-mst-13.2.git] / ext / Thread / unsync4.tx
CommitLineData
0fcb073c 1BEGIN {
2 eval { require Config; import Config };
3 if ($@) {
4 print "1..0 # Skip: no Config\n";
5 exit(0);
6 }
7 if ($Config{extensions} !~ /\bThread\b/) {
8 print "1..0 # Skip: no use5005threads\n";
9 exit(0);
10 }
11}
12
d9bb3666 13use Thread;
14
15$| = 1;
16
17srand($$^$^T);
18
19sub printargs {
20 my(@copyargs) = @_;
21 my $thread = shift @copyargs;
22 my $arg;
23 my $i;
24 while ($arg = shift @copyargs) {
25 my $delay = int(rand(500));
26 $i++;
27 print "$thread arg $i is $arg\n";
28 1 while $delay--;
29 }
30}
31
32sub start_thread {
33 my(@threadargs) = @_;
34 my $thread = $threadargs[0];
35 my $count = 10;
36 while ($count--) {
37 my(@args) = ($thread) x int(rand(10));
38 print "$thread $count calling printargs @args\n";
39 printargs($thread, @args);
40 }
41}
42
43new Thread (\&start_thread, "A");
44new Thread (\&start_thread, "B");
45new Thread (\&start_thread, "C");
46new Thread (\&start_thread, "D");
47new Thread (\&start_thread, "E");
48new Thread (\&start_thread, "F");
49
50print "main: exiting\n";