On Sat, Nov 12, 2011 at 7:24 PM, Hiroshi Nakamura <nahi / ruby-lang.org> wrote:
> # test.rb
> t1 = Thread.new { require "foo"; Foo }
> t2 = Thread.new { require "bar"; Bar }

The problem here is caused by require having a lock per file. At the
time it was added, I believe I warned it would cause deadlocks in the
future.

Yehuda's simple case could be solved by having all autoloads
synchronized against a single lock; only *either* the Foo autoload or
the Bar autoload could fire, and then the other would fire once it had
completed.

In general, if there were a single lock for requires/autoloads, there
would be no way it could deadlock.

- Charlie