From: Norman Makoto Su Date: 2002-03-29T17:04:31+09:00 Subject: Mutex problems OK, I know recently I've been posting too many messages to this mailing list, so please bear with a ruby newbie (whoa, it rhymes) =) I just tried the pickaxe book's mutex example (slightly modified): require 'thread' mutex = Mutex.new Thread.abort_on_exception = true count1 = count2 = 0 difference = 0 counter = Thread.new do loop do mutex.synchronize do count1 += 1 count2 += 2 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 puts count2 puts difference And, I get the following result: 10014 20028 67795929 Now, given my small understanding of how mutex's are supposed to work... difference should be 0 and the count vars should be equal, right? Typing ruby --version on my linux 2.0.34 system gives me: ruby 1.6.7 (2002-03-01) [i686-linux-libc1] Any help would be greatly appreciated! I have looked at old mailing lists and have noticed there are some problems with threads in window versions, but since this is in unix, I thought it should work fine. Thanks, -- Norman Makoto Su