From: Eric Armstrong Date: 2006-07-29T06:18:56+09:00 Subject: Re: ruby threads? the point? Justin Collins wrote: > Eric Armstrong wrote: >> Saw an archived message yesterday that >> said, "when one thread blocks, they all >> block". >> > > This hasn't been my experience at all. > Yay! I'd rather be wrong! > Do you have a simple example that > shows this behavior? > Below. And now that I'm at work, rather than at home, I've been able to determine that it works as expected on my Solaris box, but fails on Windows XP. (There, the display only updates after pressing spacebar or some other key.) Perhaps the problem is Curses on Windows?? --------------------------------- #!/usr/bin/env ruby require 'curses' include Curses addstr "Press spacebar to start, x to exit: " refresh timer_thread = Thread.new do 100.downto(1) do |i| addstr(".." + i.to_s) refresh sleep 1 end end begin while true c = getch case c when 32 # Space #timer_thread.run when ?x, ?X exit end end ensure Thread.kill(timer_thread) end