Skip to content

Instantly share code, notes, and snippets.

@2called-chaos
Created September 22, 2014 21:39
Show Gist options
  • Save 2called-chaos/cab6909f8e987ee40bd9 to your computer and use it in GitHub Desktop.
Save 2called-chaos/cab6909f8e987ee40bd9 to your computer and use it in GitHub Desktop.
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