From: Erik Veenstra Date: 2007-02-16T18:31:31+09:00 Subject: Re: Thread.current.parent and Thread.current.ancestors Using new_with_parent (see below) has two advantages: * By calling new_with_parent, you're saying: Yes, I know that parent doesn't work for all threads. * Thread#parent doesn't return nil for "unpatched" threads, since it doesn't exist in the first place. You can achieve the same by subclassing Thread. Disadvantage: * You can only ask for parents of your own threads. You can't ask for a parent of e.g. a DRb thread, since those aren't patched. gegroet, Erik V. - http://www.erikveen.dds.nl/ ---------------------------------------------------------------- class Thread def self.new_with_parent(*args, &block) parent = Thread.current self.new do define_method :parent do parent end block.call(*args) end end end ----------------------------------------------------------------