-
-
Save 2called-chaos/cab6909f8e987ee40bd9 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
monitor = Monitor.new | |
some_thread = Thread.new do | |
sleep 10 # something expensive | |
monitor.synchronize do | |
# Sometimes I wait minutes or longer than my patience to aquire the lock. | |
# Why? | |
end | |
end | |
# main thread | |
loop do | |
monitor.synchronize do | |
# do something | |
end | |
sleep 0.1 | |
Thread.pass | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment