Guest User

Untitled

a guest
Nov 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. require 'minitest/unit'
  2. include MiniTest::Assertions
  3.  
  4. # This is joke :p
  5.  
  6. class MyClass
  7. class << self
  8. def new
  9. return Thread.current[:local] ||= super
  10. end
  11. end
  12. end
  13.  
  14. def test
  15. puts "I'm thread #{Thread.current}"
  16. obj1 = MyClass.new
  17. obj2 = MyClass.new
  18. assert obj1 == obj2
  19. end
  20.  
  21. t1 = Thread.new { test }
  22. t2 = Thread.new { test }
  23.  
  24. t1.join
  25. t2.join
Add Comment
Please, Sign In to add comment