From: Charles Oliver Nutter Date: 2009-01-29T14:55:55+09:00 Subject: [ruby-core:21656] Re: use of require thread safety Yukihiro Matsumoto wrote: > I propose that two or more separated threads may not load same library > more than once. It can be accomplished by the behavior that Nobu > stated, or having a single lock around require. I can stand deadlock > for circular requires. Thread users must pay attention for deadlocks > anyway. Besides circular require is a bad habit. Currently JRuby will not allow the same library to load twice, but it will not detect that the library has not *finished* loading. So if two threads require the same file, one of them will actually require it and the other will see that the file has already been required and continue immediately. It may fail later if the require has not yet finished. If I understand you, a second thread requiring a file currently being required should block and wait for that require to complete, yes? Circular requires will definitely lead to deadlock, but if they're rare and strongly discouraged, I'm ok with that. - Charlie