From: Tanaka Akira Date: 2006-07-15T15:54:00+09:00 Subject: Re: [ ruby-Bugs-5067 ] open-uri fails under multithreading In article <20060715001125.5FD0B5240E0A@rubyforge.org>, writes: > The following code gives .../lib/ruby/1.8/open-uri.rb:215:in `open_http': uninitialized constant Net::HTTP (NameError) : It seems a problem of "require". % cat a.rb p [__FILE__, __LINE__] Thread.pass p [__FILE__, __LINE__] % ~/ruby/18/ruby/ruby -ve ' t1 = Thread.new { p 1 require "a" p 2 } t2 = Thread.new { p 3 require "a" p 4 } t2.join t1.join ' ruby 1.8.5 (2006-07-15) [i686-linux] 1 3 ["./a.rb", 1] 4 ["./a.rb", 3] 2 After first "require" is called, second "require" is called before the first "require" is not finished. It seems the second "require" is finished immediately, not waiting the first "require" is finished. Ruby 1.9 has no problem. % ~/ruby/19/ruby/ruby -ve ' t1 = Thread.new { p 1 require "a" p 2 } t2 = Thread.new { p 3 require "a" p 4 } t2.join t1.join ' ruby 1.9.0 (2006-07-15) [i686-linux] 1 3 ["/tmp/c/a.rb", 1] ["/tmp/c/a.rb", 3] 2 4 -- Tanaka Akira