2008/12/23 Paul Brannan <pbrannan / atdesk.com>:
> On Tue, Dec 23, 2008 at 11:32:00PM +0900, Robert Klemme wrote:
>> t1 = Thread.new do
>>   require 'a'
>>   require 'b'
>>
>>   # do all the work
>> end
>>
>> t2 = Thread.new do
>>   require 'b'
>>   require 'a' # different order for whatever reasons
>>
>>   # do different work
>> end
>
> I see no deadlock here.  The lock is released as soon as each require
> returns.

Sorry, the code was too condensed.  What I meant do depict was of course:

> There is a deadlock if a.rb and b.rb are mutually dependent, but IMO
> such a dependency is a bug.

Probably.  But rather than deadlocking we could throw an exception
because the situation could be detected.

At the moment I believe the best solution in terms of effort and
robustness is actually a single global lock plus an exception thrown
from Thread.new if the current thread holds this lock.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end