From: Joel VanderWerf Date: 2007-06-08T04:26:14+09:00 Subject: Re: raise problem in Thread 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. Even if a thread is dead, it still responds to methods. It's still an object, and all objects have a (private) #puts method that they inherit from Kernel. This is actually very useful behavior: th = Thread.new do 1+2 # or some long computation end sleep 0.1 p th.alive? # ==> false p th.value # ==> 3 The thread is dead, but you can retrieve the result. (If you call Thread#value before the thread has finished, then it waits for it to finish.) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407