From: Robert Klemme Date: 2008-02-16T07:19:57+09:00 Subject: Re: Thread safety On 15.02.2008 21:08, s.ross wrote: > On Feb 15, 2008, at 10:54 AM, Jeff Turc wrote: > >> I know it's probably hard to generalize, but does anybody have any >> simple rules to follow (or resources to share) for writing thread safe >> code? > Rule #3: If you are changing the state of an object that is not thread- > local, wrap the change in a mutex (etc.) Corollary: use thread confinement, i.e. design your app in a way that most objects are used in a single thread at a time only. Restrict need for synchronization to the minimum needed. > Rule #4: Don't be too sure that any operation in Ruby is atomic. Somehow this reminds me of "Blondie" and "Atomic". :-) Those were the days... Cheers robert