Hi, when Thread.abort_on_exception = yes I don't see any error log in the
screen. Note those cases:
case 1) It's seems correct:
---------------------
t = Thread.new {
sleep 1
qwe
}
t.abort_on_exception = true
puts "hello !!!"
sleep 2
puts "END"
---------------------
=>
hello !!!
test.rb:3: undefined local variable or method `qwe' for main:Object
(NameError)
from test.rb:1:in `initialize'
from test.rb:1:in `new'
from test.rb:1
case 2) Why the error is not shown???
---------------------
t = Thread.new {
sleep 1
qwe
}
t.abort_on_exception = false
puts "hello !!!"
sleep 2
puts "END"
---------------------
=>
hello !!!
END
case 3) But if I do a t.join then the error is shown and the program
exists !!!:
---------------------
t = Thread.new {
sleep 1
qwe
}
t.abort_on_exception = false
puts "hello !!!"
t.join
puts "END"
---------------------
=>
hello !!!
test.rb:3: undefined local variable or method `qwe' for main:Object
(NameError)
from test.rb:8:in `join'
from test.rb:8
Conclusion:
- If a thread is joined then if that threads has a non handled exception the
program will exit (except if the main program handles that exception).
- If a thread is "abort_on_exception = true" then the program will failn the
moment the thread fails (it makes sense).
- If a thead is "abort_on_exception = false" then nothing will occur ifhe
threads fails, and no error output will occur. WHY ???
Any comment is appreciated.
--
IƱaki Baz Castillo