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