From: ara.t.howard@... Date: 2006-08-22T09:09:21+09:00 Subject: Re: [BUG] thwait On Tue, 22 Aug 2006, Justin Collins wrote: > Ara.T.Howard wrote: >> >> i'm unsure if this should be expected to cause deadlock or not? >> >> ruby -r thwait -e' ThWait.all_waits(*Array.new(42){ >> Thread.new{Thread.stop} }) ' >> >> for 1.8.1 - 1.8.4 it does. >> >> thoughts? >> >> -a > > Seems like it would. You create a bunch of threads, tell them not to run, > then tell the main thread to wait on all the stopped threads. > > There's no way for this program to complete or continue. it seems like it should just hang then. otherwise this program wouldn't be able to work harp:~ > cat a.rb require 'thwait' loop{ stopped = Thread.new{ Thread.stop } notify = Thread.new{ stopped.wakeup } ThWait.all_waits stopped } this code __should__ be able to run - but it won't. the docs say: harp:~ > ri ThreadsWait ----------------------------------------------------- Class: ThreadsWait This class watches for termination of multiple threads. Basic functionality (wait until specified threads have terminated) can be accessed through the class method ThreadsWait::all_waits. Finer control can be gained using instance methods. a sleeping thread has not terminated, but whose to say it won't at some point in the future? for instance. this is valid ruby ruby -e' Thread.new{ sleep }.join ' it just hangs forever. similarly i feel that ThWait.all_waits Thread.new{ sleep } should also hang - not deadlock. regards. -a -- to foster inner awareness, introspection, and reasoning is more efficient than meditation and prayer. - h.h. the 14th dali lama