Commit | Line | Data |
---|---|---|
0fcb073c JH |
1 | BEGIN { |
2 | eval { require Config; import Config }; | |
3 | if ($@) { | |
4 | print "1..0 # Skip: no Config\n"; | |
5 | exit(0); | |
6 | } | |
0fcb073c JH |
7 | } |
8 | ||
d9bb3666 MB |
9 | use Thread; |
10 | ||
11 | $| = 1; | |
12 | ||
13 | srand($$^$^T); | |
14 | ||
15 | sub printargs { | |
16 | my(@copyargs) = @_; | |
17 | my $thread = shift @copyargs; | |
18 | my $arg; | |
19 | my $i; | |
20 | while ($arg = shift @copyargs) { | |
21 | my $delay = int(rand(500)); | |
22 | $i++; | |
23 | print "$thread arg $i is $arg\n"; | |
24 | 1 while $delay--; | |
25 | } | |
26 | } | |
27 | ||
28 | sub start_thread { | |
29 | my(@threadargs) = @_; | |
30 | my $thread = $threadargs[0]; | |
31 | my $count = 10; | |
32 | while ($count--) { | |
33 | my(@args) = ($thread) x int(rand(10)); | |
34 | print "$thread $count calling printargs @args\n"; | |
35 | printargs($thread, @args); | |
36 | } | |
37 | } | |
38 | ||
39 | new Thread (\&start_thread, "A"); | |
40 | new Thread (\&start_thread, "B"); | |
41 | new Thread (\&start_thread, "C"); | |
42 | new Thread (\&start_thread, "D"); | |
43 | new Thread (\&start_thread, "E"); | |
44 | new Thread (\&start_thread, "F"); | |
45 | ||
46 | print "main: exiting\n"; |