This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move perlext/Thread into perl/ext/Thread.
[perl5.git] / ext / Thread / io.t
CommitLineData
d9bb3666
MB
1use Thread;
2
3sub 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
609f3ea9
MB
12print <<'EOT';
13This test starts up a thread to read and echo whatever is typed on
14the keyboard/stdin, line by line, while the main thread counts down
15to zero. The test stays running until both the main thread has
16finished counting down and the I/O thread has seen end-of-file on
17the terminal/stdin.
18EOT
19
d9bb3666 20$r = new Thread \&reader;
609f3ea9 21$count = 10;
d9bb3666
MB
22while ($count--) {
23 sleep 1;
24 print "ping $count\n";
25}