Created
October 24, 2012 18:27
-
-
Save anonymous/3947901 to your computer and use it in GitHub Desktop.
This file contains 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
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