From: ara.t.howard@... Date: 2007-01-04T01:41:12+09:00 Subject: Re: Problem in Unit Testing Methods that start new threads On Thu, 4 Jan 2007, Mat Schaffer wrote: > > Ara's right on this one. It's a race condition. But it looks like you're > interested in checking that the thread has indeed started. If I were to > write something like this I would probably have the unit test run > @foo.new_thread_start and immediately sleep waiting for a signal from the > child thread. The child thread would then signal back to the any waiting > threads that it had set it's thread status to true. Altough the more I > ponder it, the more I feel like I've just moved the race condition to the > sleep call. I'll have to review my concurrent programming texts a bit. > Seems like you should do the same. > > Either way, check out Monitor for some insight: > http://www.ruby-doc.org/stdlib/libdoc/monitor/rdoc/index.html > > -Mat good idea mat. it's easy in ruby too: require 'thread' q = Queue.new Thread.new{ q.push :running # run } q.pop # wait for thread to start... regards. -a -- if you find yourself slandering anybody, first imagine that your mouth is filled with excrement. it will break you of the habit quickly enough. - the dalai lama