From: Rick DeNatale Date: 2007-06-08T04:30:27+09:00 Subject: Re: raise problem in Thread On 6/7/07, Oliver Peng wrote: > Hi Joel: > > Thank you for your reply. > > One thing I am a little confused is that the main thread continues > executing the puts "hello". From my point of view, puts "hello" is part > of method test_raise. So after the exception was raised and the MyThread > instance was dead, the method should stopping running and just return > nil to main thread. Why main thread need to continue running left part > of this method? This can cause some unexpecting problems. As Joel explained, the puts is runs on the current thread, but the exception is raised on the other thread. Just because some code is a method of a thread class doesn't mean that it automatically runs on any particular thread. Let's try a little change to your code, change that puts "Hello" to puts "I am #{self}, current thread is #{Thread.current}". Now in irb: irb(main):013:0> thread = MyThread.new started=> # irb(main):014:0> thread.test_raise I am #, current_thread is # => nil irb(main):015:0> Thread.current => # Does that help? -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/