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

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

perl 5.8.8

File size: 792 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
11sub counter {
12$count = 10;
13while ($count--) {
14 sleep 1;
15 print "ping $count\n";
16}
17}
18
19sub reader {
20 my $line;
21 while ($line = <STDIN>) {
22 print "reader: $line";
23 }
24 print "End of input in reader\n";
25 return 0;
26}
27
28print <<'EOT';
29This test starts up a thread to read and echo whatever is typed on
30the keyboard/stdin, line by line, while the main thread counts down
31to zero. The test stays running until both the main thread has
32finished counting down and the I/O thread has seen end-of-file on
33the terminal/stdin.
34EOT
35
36$r = new Thread \&counter;
37
38&reader;
39
40__END__
41
42
43$count = 10;
44while ($count--) {
45 sleep 1;
46 print "ping $count\n";
47}
Note: See TracBrowser for help on using the repository browser.