Skip to content

Instantly share code, notes, and snippets.

Created October 24, 2012 18:27
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 anonymous/3947901 to your computer and use it in GitHub Desktop.
Save anonymous/3947901 to your computer and use it in GitHub Desktop.
running = true
mutex = Mutex.new
thr = Thread.new do
while mutex.synchronize{running}
sleep 1
end
end
sleep 2
#what is better
mutex.synchronize{running = false}
# or #1
running = false
# or #2
thr[:running] = false
#or #3
mutex.synchronize{thr[:running = false]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment