【发布时间】:2014-11-11 21:14:44
【问题描述】:
如何在不使用.join的情况下观察和挽救线程中发生的错误?我现在拥有的代码:
Thread.abort_on_exception = true
begin
a = Thread.new { errory_code }
rescue Exception => detail
puts detail.message
end
sleep 1 #so that thread has enough time to execute
如果我理解正确,Thread.abort_on_exception = true 会中止线程执行(即引发异常)。但是为什么救援没有抓住它呢?
【问题讨论】:
标签: ruby multithreading