Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'minitest/unit'
- include MiniTest::Assertions
- # This is joke :p
- class MyClass
- class << self
- def new
- return Thread.current[:local] ||= super
- end
- end
- end
- def test
- puts "I'm thread #{Thread.current}"
- obj1 = MyClass.new
- obj2 = MyClass.new
- assert obj1 == obj2
- end
- t1 = Thread.new { test }
- t2 = Thread.new { test }
- t1.join
- t2.join
Add Comment
Please, Sign In to add comment