ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/staticperl/perl/ext/Thread/unsync.tx
Revision: 1.1
Committed: Thu Jun 30 14:27:05 2005 UTC (21 years, 3 months ago) by root
Branch: MAIN
CVS Tags: PERL-5-8-7, HEAD
Branch point for: PERL
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 BEGIN {
2     eval { require Config; import Config };
3     if ($@) {
4     print "1..0 # Skip: no Config\n";
5     exit(0);
6     }
7     }
8    
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");
33     print "start_foo: finished\n";
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");
40     print "start_bar: finished\n";
41     }
42    
43     $foo = new Thread \&start_foo;
44     $bar = new Thread \&start_bar;
45     print "main: exiting\n";