This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add socklen_t probe; Configure maintenance.
[perl5.git] / ext / Thread / unsync3.t
CommitLineData
d9bb3666
MB
1use Thread;
2
3$| = 1;
4
5srand($$^$^T);
6
7sub whoami {
8 my $thread = shift;
9 print $thread;
10}
11
12sub uppercase {
13 my $count = 100;
14 while ($count--) {
15 my $i = int(rand(1000));
16 1 while $i--;
17 print "A";
18 $i = int(rand(1000));
19 1 while $i--;
20 whoami("B");
21 }
22}
23
24sub lowercase {
25 my $count = 100;
26 while ($count--) {
27 my $i = int(rand(1000));
28 1 while $i--;
29 print "x";
30 $i = int(rand(1000));
31 1 while $i--;
32 whoami("y");
33 }
34}
35
36sub numbers {
37 my $count = 100;
38 while ($count--) {
39 my $i = int(rand(1000));
40 1 while $i--;
41 print 1;
42 $i = int(rand(1000));
43 1 while $i--;
44 whoami(2);
45 }
46}
47
48new Thread \&numbers;
49new Thread \&uppercase;
50new Thread \&lowercase;