From: "S.Z." Date: 2005-10-11T22:51:53+09:00 Subject: Re: How to overload Object's methods automagicaly? Robert Klemme wrote: > S.Z. wrote: > > What is the better choice? > > You can iterate all instance methods, alias each one and create a new one > calling the original one synchronized. Delegate might be helpful, too. Eurica! I need not to define, but rather to undefine the Object's methods: undef :to_s, :taint, :clone; Now method_missing() can operate. > Note though that automatically synchronizaton of each method is not > necessarily going to make your program thread safe. Every transaction > that involves more than one method invocation won't be thread safe with > this approach - in this case you need explicit external synchronization Any transaction on an object can be treated as a single method call. Transaction's body can be known only at runtime; but it is not a problem in Ruby. > Sun stepped away from > full synchronization (Vector, StringBuffer) and added classes that do not > employ method level synchronization (ArrayList, StringBuilder), which is > more performant. This approach is erroprone, I think... -- many thanks