From: Issac Date: 2001-12-09T11:44:11+09:00 Subject: [ruby-talk:27987] mutex problem As a Ruby newbie, I've been excitedly plowing through the Thomas/Hunt book. But now I'm stuck. On pp. 118-119 there's a piece of code that doesn't seem to work: require 'thread' mutex = Mutex.new count1 = count2 = 0 difference = 0 counter = Thread.new do loop do mutex.sychronize do count1 += 1 count2 += 1 end end end spy = Thread.new do loop do mutex.synchronize do difference += (count1 - count2).abs end end end sleep 1 mutex.lock puts "count1 = #{count1}" puts "count2 = #{count2}" puts "difference = #{difference}" When I run this on ruby 1.6.5 (2001-09-19) [i386-cygwin] from the cygwin command line, it hangs. It also hangs when I run it in RubyWin 0.0.3.8 with the same version of ruby. Can anyone help?