From: Nasir Khan Date: 2007-06-09T06:54:04+09:00 Subject: Re: Synchronized attr_accessor There is no big picture. The problem is simple - "create accessors for an instance variable that access the variable under a lock". Just as problem statement for "attr_accessor" could be - "create accessors for instance variables" - Nasir PS: I understand that a synchronized access to hash is not the same as synchronized access to hash values, but this problem is *not* about it. On Jun 8, 2:13 pm, MenTaLguY wrote: > On Sat, 9 Jun 2007 04:55:24 +0900, Nasir Khan wrote: > > This is about having a instance variable always accessed under a lock, > > if object state (instance variables) are accessed by many threads at > > the same time for eg. a hash accessed by several threads for getting values but some > > operation also adding deleting from the hash. You would want a > > synchronized access to your hash in this case... > > Just because access to an instance variable is synchronized does not mean that access to the object it references is synchronized. Retrieving a hash object via a synchronized accessor does not make it safe against concurrent modification. > > There are approaches which will work, but to know which ones to suggest, I will need to know more about the "bigger picture" that this code is part of. > > -mental