From: Me Me Date: 2008-06-30T18:07:04+09:00 Subject: Sleep in a multithreaded environment Hi, I'm trying to control an external process I'm running and quit it in case it got stuck. To do that I have to check that the external exe keeps writing on stdout, if it doesn't update it for a while I'll quit it. I came up with the following code (using threads) but the sleep in the main thread blocks everything. (The same code works under Mac OSX) Is there something I'm doing wrong? Or a better way to achieve what I need? Thanks a lot in advance n = 0 t1 = Thread.new { begin IO.popen("executable.exe") do |pipe| pipe.each("\r") do |line| puts line n += 1 end end end } k = 0 while t1.alive? sleep(10) # DOESN'T SEEM TO WORK ON WINDOWS if k == n puts "DEAD" t1.raise("close") end k = n end -- Posted via http://www.ruby-forum.com/.