in reply to perl threads wait application?

You might want to put $|++ in your main script to avoid buffering output, but with the \n in there, it should print anyways.

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" ; } }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: perl threads wait application?
by BrowserUk (Patriarch) on May 17, 2007 at 18:14 UTC
      You are right. I can't recall exactly why, but in some hacking in the past, I found that the FileHandle method had some benefit if you wanted both keyboard and pipe input. I can't reproduce the problem now, so I stand corrected..... no more muddy water. :-)

      I'm not really a human, but I play one on earth. Cogito ergo sum a bum