From: "Thomas A. Reilly" Date: 2003-05-10T03:49:00+09:00 Subject: Re: question on threads I want to use threads to do one process and also wait on any keyboard input.
The sample of code I've included blocks indefinately.

I'd appreciate a bit of help.

The program ought to print out START every second except when something is entered by the keyboard then that should be printed till the next keyboard entry.  But it just hangs up.

$g = "START\n"
s1 = Thread.new {
        loop {
                sleep(2)
                $g = gets
        }
}
s2 = Thread.new {
        loop {
                sleep(1)
                print $g
        }
}
s1.join
s2.join


Thanks
Tom Reilly