source: trunk/essentials/dev-lang/perl/ext/Thread/unsync3.tx

Last change on this file was 3181, checked in by bird, 18 years ago

perl 5.8.8

File size: 806 bytes
Line 
1BEGIN {
2 eval { require Config; import Config };
3 if ($@) {
4 print "1..0 # Skip: no Config\n";
5 exit(0);
6 }
7}
8
9use Thread;
10
11$| = 1;
12
13srand($$^$^T);
14
15sub whoami {
16 my $thread = shift;
17 print $thread;
18}
19
20sub uppercase {
21 my $count = 100;
22 while ($count--) {
23 my $i = int(rand(1000));
24 1 while $i--;
25 print "A";
26 $i = int(rand(1000));
27 1 while $i--;
28 whoami("B");
29 }
30}
31
32sub lowercase {
33 my $count = 100;
34 while ($count--) {
35 my $i = int(rand(1000));
36 1 while $i--;
37 print "x";
38 $i = int(rand(1000));
39 1 while $i--;
40 whoami("y");
41 }
42}
43
44sub numbers {
45 my $count = 100;
46 while ($count--) {
47 my $i = int(rand(1000));
48 1 while $i--;
49 print 1;
50 $i = int(rand(1000));
51 1 while $i--;
52 whoami(2);
53 }
54}
55
56new Thread \&numbers;
57new Thread \&uppercase;
58new Thread \&lowercase;
Note: See TracBrowser for help on using the repository browser.