From: Philip Mak Date: 2003-08-25T10:54:46+09:00 Subject: How did this variable become negative? My program crashed with this error: ./throttle.rb:42:in `/': divided by 0 (ZeroDivisionError) The offending line is this: limit = $THROTTLE / (@@num_sending + 1) So that means @@num_sending must have become -1 somehow, in order for a ZeroDivisionError to occur. But @@num_sending is initialized to 0, and this is the only place in the code where it is modified: begin @@num_sending += 1 yield limit ensure @@num_sending -= 1 end So how could @@num_sending have become -1? It can only be decremented after being incremented. Could the fact that this class is used by multiple threads simultaneously have something to do with it? But I still don't see how it could happen... ruby 1.6.8 (2002-12-24) [i686-linux]