> Move the lock inside the begin/ensure/end block. This way, > you don't have a case where Mutex#lock fails throwing an > exception but you still access the array. Hmm ... I guess your way is safer -- but for it to matter, there'd have to be a case where Mutex#lock was called, successfully locked the Mutex, then threw an exception. But as you said, I'm not familiar with how its implemented, so perhaps that is a possibility (even if it's rare). > Why not this: > > def ==(x) > begin > @mutex.lock > @internalArray == x.ary > ensure > @mutex.unlock > end > end > > Okay, maybe that's ugly. Hmm. I think that's how it'd have to be. I forgot that Array#== already did a comparison of content, not actual instance ids, so I didn't think about this option in the first place. Chris