Thread interruptable too early?

Hmm. Question.

Imagine you've got this code:
a = Thread.new {
begin
# do stuff
rescue MyException
end
}
a.raise MyException.new

Is it possible that this will still result in an uncaught exception
within thread a? Thoughts?
Thank you!
-Roger

···

--
Posted via http://www.ruby-forum.com/.

Thread#raise is bad, in general, for worse reasons than that:

  t = Thread.new {
    begin
      allocate_resource()
      do_something()
    ensure
      cleanup_resource()
    end
  }
  sleep 1
  t.raise SomeException.new

If the thread is in cleanup when Thread#raise is called, then cleanup
will fail, which is probably not the desired behavior.

There are plenty other examples I've seen as well.

Paul

···

On Wed, Sep 05, 2007 at 06:47:29AM +0900, Roger Pack wrote:

Hmm. Question.

Imagine you've got this code:
a = Thread.new {
begin
# do stuff
rescue MyException
end
}
a.raise MyException.new

Is it possible that this will still result in an uncaught exception
within thread a? Thoughts?
Thank you!
-Roger
--
Posted via http://www.ruby-forum.com/\.