From: matz@... (Yukihiro Matsumoto) Date: 2002-12-18T17:59:38+09:00 Subject: Re: Threads raising exceptions Hi, In message "Threads raising exceptions" on 02/12/18, Tim Bates writes: |I have the following piece of threading code: | |Thread.new(i) do |j| | #$SAFE = 4 | b = 0 | loop do | b += 1 | raise 'Test' if j == 3 and b == 100 | sleep(0) | end |end | |This behaves as expected - if Thread.abort_on_exception is true, the program |throws an exception and dies, otherwise just this thread dies, and no |exception I can rescue. So far, so good. | |If, however, I uncomment the line with $SAFE = 4, it behaves as if |Thread.abort_on_exception is false, and so I can't catch any exception when a |thread dies, and so I can't find out what happened, which I need to! What can |I do about this? use Thread#join or Thread#value to retrieve exception from the dead thread. It is so to avoid process termination by exceptions from untrusted code. For debugging, $DEBUG=true will print exception names. matz.