Commit | Line | Data |
---|---|---|
d9bb3666 MB |
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 | ||
609f3ea9 MB |
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 | ||
d9bb3666 | 20 | $r = new Thread \&reader; |
609f3ea9 | 21 | $count = 10; |
d9bb3666 MB |
22 | while ($count--) { |
23 | sleep 1; | |
24 | print "ping $count\n"; | |
25 | } |