Rename the old non-standard threads tests so that
[p5sagit/p5-mst-13.2.git] / ext / Thread / unsync2.tx
1 BEGIN {
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
13 use Thread;
14
15 $| = 1;
16
17 srand($$^$^T);
18
19 sub printargs {
20     my $thread = shift;
21     my $arg;
22     my $i;
23     while ($arg = shift) {
24         my $delay = int(rand(500));
25         $i++;
26         print "$thread arg $i is $arg\n";
27         1 while $delay--;
28     }
29 }
30
31 sub start_thread {
32     my $thread = shift;
33     my $count = 10;
34     while ($count--) {
35         my(@args) = ($thread) x int(rand(10));
36         print "$thread $count calling printargs @args\n";
37         printargs($thread, @args);
38     }
39 }
40
41 new Thread (\&start_thread, "A");
42 new Thread (\&start_thread, "B");
43 #new Thread (\&start_thread, "C");
44 #new Thread (\&start_thread, "D");
45 #new Thread (\&start_thread, "E");
46 #new Thread (\&start_thread, "F");
47
48 print "main: exiting\n";