Created
June 30, 2013 23:39
-
-
Save hiremaga/5897486 to your computer and use it in GitHub Desktop.
A spike to demostrate the thread (un)safety of autoload, stolen from somwhere I can't remember
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sleep 1 | |
Bar::Foo = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Bar | |
autoload :Foo, 'autoloaded.rb' | |
end | |
t1 = Thread.new { Bar::Foo } | |
t2 = Thread.new { Bar::Foo } | |
t1.join; t2.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment