From: Joel VanderWerf Date: 2003-08-26T14:17:03+09:00 Subject: Re: fxRuby and errors Fredrik Jagenheim wrote: > On Mon, Aug 25, 2003 at 05:28:00AM +0900, Joel VanderWerf wrote: > >>See if this helps: >> >>Thread.abort_on_exception = true >> >>(assign this at the start of your code). Otherwise, threads other than >>the main thread die silently. > > > Yes, that worked perfectly. Thanks. > > But it brought me no closer to understanding what really happened to > the thread that threw the exception. > > Setting abort_on_exception to true indicates that it doesn't /abort/ > when you get an exception by default, and you say it 'dies silently'. > > So, correct me if I'm wrong, the thread dies, and lies dormant until > reaped by Tread.join? Actually, when I typed that I think I understand > what really happened. When the thread died due to the exception, it > was suspended. When join was called, the thread was 'promoted' to the > main thread with an uncatched exception. And since the main thread > always abort on uncatched exceptions, we get a 'verbose' abort. I'm not really sure either, but your explanation makes sense, and here's what irb says: irb(main):001:0> t = Thread.new { raise} => # irb(main):002:0> Thread.list => [#] irb(main):003:0> t.join RuntimeError: from (irb):1 from (irb):3:in `join' from (irb):3 irb(main):004:0> begin; t.join; rescue Exception; puts "CAUGHT!"; end CAUGHT! => nil So apparently the thread is 'dead', which is probably not the same thing as suspended. But a dead thread can still be joined and you can catch its exception (more than once, it seems). Hm, that's good to know.