From: MenTaLguY Date: 2008-03-26T03:11:55+09:00 Subject: Re: thread.rb On Tue, 25 Mar 2008 20:57:48 +0900, "Robert Klemme" wrote: > I opt against using Thread.critical because this is a global exclusive > lock on all threads and it is unlikely to continue to exist in the > light of JRuby and others. I'd rather use Mutex#try_lock or Monitor's > #wait with timeout parameter. Agreed, anything using Thread.critical is not very future-proof. Note, however, that while Monitor is okay under JRuby, in MRI (1.9 at least) it uses Timeout in an uncontrolled way and is not entirely reliable as a result. To implement Monitor robustly in JRuby we ended up adding timeout support to JRuby's ConditionVariable#wait. *** I would strongly recommend _against_ using any concurrency primitive in 1.9 except for the primitives from thread.rb/thread.so. *** Given that, the most directly portable way to get a robust queue that supports timeouts is to roll your own using Mutex, ConditionVariable, and some safe source of timed events like Scheduler. -mental