From: Stephen Ware Date: 2007-10-04T07:25:03+09:00 Subject: Re: Non-blocking 'gets' ? > It doesn't sound like you are writing a multi-threaded application if > gets hangs all your threads. The whole point of threads is to execute > other blocks of code while there is idle time in a given block of code. Well... I think my code is written properly. For simplicity's sake, let's consider it a chat room. The main thread spawns a "listener" thread and then sleeps forever. The listener thread listens for socket connections on a port and spawns a new thread for each socket, basically allowing multiple users to connect at the same time and interact with one another. That much works, and I have logged in with multiple users to test it. The change I'm trying to make is in the main thread... instead of sleeping forever, I want to accept commands from STDIN, such as 'shutdown,' for example. But when I replaced 'sleep(0)' with an infinite loop of 'command = gets', it freezes the whole application. I am no longer able to connect, even with one user. Actually, it will still connect but only if I type characters into STDIN very rapidly. That's what leads me to conclude that 'gets' is hanging all my threads. -- Posted via http://www.ruby-forum.com/.