Skip to content

Instantly share code, notes, and snippets.

@Ptico
Created April 17, 2015 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ptico/002eb8731d5c04c011e0 to your computer and use it in GitHub Desktop.
Save Ptico/002eb8731d5c04c011e0 to your computer and use it in GitHub Desktop.
class A
attr_accessor :foo
def initialize
@mutex = Mutex.new
end
def perform
t1 = Thread.new do
@foo ||= 10
end
t2 = Thread.new do
@foo ||= 20
end
t1.join
t2.join
end
end
10.times do
a = A.new
a.perform
puts a.foo
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment