From: James Edward Gray II Date: 2004-10-07T00:10:38+09:00 Subject: Re: Thinking about Threaded IO On Oct 6, 2004, at 9:59 AM, Kevin McConnell wrote: > Brian Candler wrote: > >> IO#read and IO#gets work properly; in other words Ruby wraps the calls >> appropriately to make sure they never block the interpreter engine. > > Not sure if any of you use Windows, but it's probably worth pointing > out that on Windows IO#gets *does* block all threads. > > E.g. if I run the following: > > thread = Thread.new { i=0; while(true); puts i+=1; sleep 1; end } > sleep 10 > str = $stdin.gets > sleep 10 > > It should display the numbers 1 to 10, and then go suspiciously quiet > until you provide the input to gets. Once you do that, you'll get the > numbers 11 to 20. It's that because you are calling gets() on STDIN here? Would it behave the same if we were dealing with sockets instead? James Edward Gray II