in reply to perl threads wait application?
I think your problem is your "read STDIN, $stuff,10" statement. It will wait for 10 chars, try "read STDIN,$stuff, 1". That works on linux.
If you want readline on the stdin, try this
#!/usr/bin/perl use FileHandle; use threads; $|++; $thr = threads->new(\&sub1); sub sub1 { while(1){ print "THREAD: in da zone !! :) \n\n"; sleep 1; }; } my $fh_in = FileHandle->new(); $fh_in = *STDIN{IO}; + while (<$fh_in>) { + my $stuff = $_; if (defined($stuff) and $stuff ne ''){ print "MAIN:", $stuff , "\n" ; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl threads wait application?
by BrowserUk (Patriarch) on May 17, 2007 at 18:14 UTC | |
by zentara (Cardinal) on May 18, 2007 at 11:32 UTC |