From: matz@... (Yukihiro Matsumoto) Date: 2004-01-24T16:59:39+09:00 Subject: Re: Problem with Exceptions and Threads Hi, In message "Problem with Exceptions and Threads" on 04/01/24, Pit Capitain writes: |recently I had a problem writing unit tests using timeout.rb and other |threads. The smallest reproducible testcase I came up with is this: When the main thread terminates, the other threads are terminated automagically. Thus |# test_own_error_in_thread => works This works by accident. The execution of the threads reaches end before context switch. Thus adding "join" at the end of Thread#new would help: |begin | main = Thread.current | Thread.new do | begin | Thread.new do end # this line makes the difference | raise TestError, "error3" | rescue Exception | main.raise $! | end | end.join # <-- note ".join" here |rescue TestError | puts $! # doesn't print "error3" |end matz.