Hi -- On Fri, 22 Nov 2002, Paul Brannan wrote: > On Fri, Nov 22, 2002 at 12:47:32AM +0900, dblack / candle.superlink.net wrote: > > def self.my_new > > obj = new > > class << obj; public :other_initialize; end > > obj.other_initialize > > class << obj; private :other_initialize; end > > obj > > end > > This isn't thread-safe. Consider: > 1) I create two objects > 2) The first constructor makes other_initialize public > 3) The second constructor makes other_initialize public > 4) The first constructor calls other_initialize > 5) The first constructor makes other_initialize private > 6) The second constructor will fail when it calls other_initialize > > It's also possible to call other_initialize from one thread while > another thread is constructing one of these objects. I think the privacy is gate-kept separately by each object's singleton class: class A def talk; puts "hi"; end private :talk end a = A.new class << a; public :talk; end a.talk # hi b = A.new b.talk # error: private method called so the manipulation of the privacy should itself be private and atomic. David -- David Alan Black home: dblack / candle.superlink.net work: blackdav / shu.edu Web: http://pirate.shu.edu/~blackdav