abort_on_exception=

Thread.abort_on_exception= boolean â true or false
Class Public methods

When set to true, all threads will abort if an exception is raised. Returns the new state.

Thread.abort_on_exception = true
t1 = Thread.new do
  puts  "In new thread"
  raise "Exception from thread"
end
sleep(1)
puts "not reached"

produces:

In new thread
prog.rb:4: Exception from thread (RuntimeError)
 from prog.rb:2:in `initialize'
 from prog.rb:2:in `new'
 from prog.rb:2
doc_ruby_on_rails
2015-05-17 11:35:47
Comments
Leave a Comment

Please login to continue.