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 | } |
7 | if ($Config{extensions} !~ /\bThread\b/) { |
8 | print "1..0 # Skip: no use5005threads\n"; |
9 | exit(0); |
10 | } |
11 | } |
12 | |
d9bb3666 |
13 | use Thread; |
14 | |
15 | $| = 1; |
16 | |
17 | srand($$^$^T); |
18 | |
19 | sub whoami { |
20 | my $thread = shift; |
21 | print $thread; |
22 | } |
23 | |
24 | sub uppercase { |
25 | my $count = 100; |
26 | while ($count--) { |
27 | my $i = int(rand(1000)); |
28 | 1 while $i--; |
29 | print "A"; |
30 | $i = int(rand(1000)); |
31 | 1 while $i--; |
32 | whoami("B"); |
33 | } |
34 | } |
35 | |
36 | sub lowercase { |
37 | my $count = 100; |
38 | while ($count--) { |
39 | my $i = int(rand(1000)); |
40 | 1 while $i--; |
41 | print "x"; |
42 | $i = int(rand(1000)); |
43 | 1 while $i--; |
44 | whoami("y"); |
45 | } |
46 | } |
47 | |
48 | sub numbers { |
49 | my $count = 100; |
50 | while ($count--) { |
51 | my $i = int(rand(1000)); |
52 | 1 while $i--; |
53 | print 1; |
54 | $i = int(rand(1000)); |
55 | 1 while $i--; |
56 | whoami(2); |
57 | } |
58 | } |
59 | |
60 | new Thread \&numbers; |
61 | new Thread \&uppercase; |
62 | new Thread \&lowercase; |