resync with mainline
[p5sagit/p5-mst-13.2.git] / ext / Thread / io.t
CommitLineData
d9bb3666 1use Thread;
2
17f28c40 3sub counter {
4$count = 10;
5while ($count--) {
6 sleep 1;
7 print "ping $count\n";
8}
9}
10
d9bb3666 11sub reader {
12 my $line;
13 while ($line = <STDIN>) {
14 print "reader: $line";
15 }
16 print "End of input in reader\n";
17 return 0;
18}
19
609f3ea9 20print <<'EOT';
21This test starts up a thread to read and echo whatever is typed on
22the keyboard/stdin, line by line, while the main thread counts down
23to zero. The test stays running until both the main thread has
24finished counting down and the I/O thread has seen end-of-file on
25the terminal/stdin.
26EOT
27
17f28c40 28$r = new Thread \&counter;
29
30&reader;
31
32__END__
33
34
609f3ea9 35$count = 10;
d9bb3666 36while ($count--) {
37 sleep 1;
38 print "ping $count\n";
39}