Created
April 30, 2014 20:01
-
-
Save benweint/cd2d1d3550c035d67b0d to your computer and use it in GitHub Desktop.
Demonstration of issue with MonitorMixin on Ruby 1.8
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'thread' | |
require 'rubygems' | |
require 'monitor' | |
class Dummy | |
include MonitorMixin | |
def sync | |
self.synchronize { } | |
end | |
end | |
q = Queue.new | |
t = Thread.new do | |
puts "bmw: before sync" | |
Dummy.new.sync | |
puts "bmw: after sync" | |
q.push 'go ahead, other thread' | |
sleep | |
end | |
q.pop # wait until thread pushes to q | |
t.run | |
t.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment