Skip to content

Instantly share code, notes, and snippets.

@benweint
Created April 30, 2014 20:01
Show Gist options
  • Save benweint/cd2d1d3550c035d67b0d to your computer and use it in GitHub Desktop.
Save benweint/cd2d1d3550c035d67b0d to your computer and use it in GitHub Desktop.
Demonstration of issue with MonitorMixin on Ruby 1.8
#!/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