From: Logan Capaldo Date: 2006-04-25T01:19:43+09:00 Subject: Re: How do threads and join work? On Apr 23, 2006, at 7:35 AM, Pat Maddox wrote: > Right, I mentioned that in my OP. I want to know if there's a way to > get join-like behavior - do not terminate the program until that > thread has finished executing - without blocking. Have you considered the possibility that you're either a) doing things in the wrong order or b) have your infinite loop in the wrong thread. You can just make #join the last thing you do, that's effectively "non-blocking" e.g. t = Thread.start { ... } # do other stuff in main thread t.join # no code follows this anyway Or if the thread should drive the running of the other stuff: require 'mutex' m = Mutex.new is_running = true t = Thread.start do while getting_stuff_or_whatever do_stuff( ) end # we stopped getting stuff m.synchronize { is_running = false } end local_running = nil m.synchronize { local_running = is_running } while local_running do_other_stuff m.synchronize do unless is_running local_running = false end end end Of course this example is silly you should probably use a queue