Reverse integrate Malcolm's chanes into local
[p5sagit/p5-mst-13.2.git] / ext / Thread / io.t
1 use Thread;
2
3 sub reader {
4     my $line;
5     while ($line = <STDIN>) {
6         print "reader: $line";
7     }
8     print "End of input in reader\n";
9     return 0;
10 }
11
12 print <<'EOT';
13 This test starts up a thread to read and echo whatever is typed on
14 the keyboard/stdin, line by line, while the main thread counts down
15 to zero. The test stays running until both the main thread has
16 finished counting down and the I/O thread has seen end-of-file on
17 the terminal/stdin.
18 EOT
19
20 $r = new Thread \&reader;
21 $count = 10;
22 while ($count--) {
23     sleep 1;
24     print "ping $count\n";
25 }