Commit | Line | Data |
0fcb073c |
1 | BEGIN { |
2 | eval { require Config; import Config }; |
3 | if ($@) { |
4 | print "1..0 # Skip: no Config\n"; |
5 | exit(0); |
6 | } |
0fcb073c |
7 | } |
8 | |
d9bb3666 |
9 | use Thread; |
10 | |
11 | $| = 1; |
12 | |
13 | if (@ARGV) { |
14 | srand($ARGV[0]); |
15 | } else { |
16 | my $seed = $$ ^ $^T; |
17 | print "Randomising to $seed\n"; |
18 | srand($seed); |
19 | } |
20 | |
21 | sub whoami { |
22 | my ($depth, $a, $b, $c) = @_; |
23 | my $i; |
24 | print "whoami ($depth): $a $b $c\n"; |
25 | sleep 1; |
26 | whoami($depth - 1, $a, $b, $c) if $depth > 0; |
27 | } |
28 | |
29 | sub start_foo { |
30 | my $r = 3 + int(10 * rand); |
31 | print "start_foo: r is $r\n"; |
32 | whoami($r, "start_foo", "foo1", "foo2"); |
783070da |
33 | print "start_foo: finished\n"; |
d9bb3666 |
34 | } |
35 | |
36 | sub start_bar { |
37 | my $r = 3 + int(10 * rand); |
38 | print "start_bar: r is $r\n"; |
39 | whoami($r, "start_bar", "bar1", "bar2"); |
783070da |
40 | print "start_bar: finished\n"; |
d9bb3666 |
41 | } |
42 | |
43 | $foo = new Thread \&start_foo; |
44 | $bar = new Thread \&start_bar; |
45 | print "main: exiting\n"; |