Question: Thread#kill doesn't throw Exception

$B!!$5$5$@$G$9!%(B

$B!!HsF14|Nc30$I$&$d$C$F=hM}$rCY1d$5$;$h$&$+$H9M$($$$F!$5?Ld$K$"$?$C$?$N$G(B
$B<ALd$5$;$F2<$5$$!%(B

$B<ALd!’(B
$B!!(BThread#kill$B!$$*$h$S(B exit $B$7$?$H$-B>$N%9%l%C%I$r(B cancel
$B$5$;$k3d$j9~$_(B
$B$O!$Ev3:%9%l%C%I$KNc30$rHt$P$9$N$G$O$J$/!$$$$o$PFC<l$J(B object $B$r(B
throw
$B$r$7$F$$$k$h$&$J$N$G$9$,!$$I$&$7$F$=$&$J$s$G$7$?$C$1!%$?$H$($P!$$=$l$>$l(B
ThreadKilledException $B$H$+(B ThreadCancelException
$B$rHt$P$7$F$bNI$5$=$&$J(B
$B5$$O$9$k$N$G$9$,!%(B

$B!!(Brescue $B$5$;$?$/$J$$$+$i!)(B

$B<ALd$NGX7J!’(B
$B!!(B"[ruby-dev:45816] Re:
$BHsF14|3d$j9~$$KBP$9$kBP=h0F!JF|K\8lHG!K(B" $B$G=q$-(B
$BD>$7$?!$(Bakr $B$5$sDs0F$N(B API
$B$O!$$"$kNc30%/%i%9$G$N%9%l%C%I$N3d$j9~$
$rCY(B
$B1d$5$;$^$9!%$7$+$7!$>e5-$NHsF14|3d$j9~$$O!$Nc30$G$O$J$$$?$a!$3d$j9~$$r(B
$B6X;_$9$k$3$H$,=PMh$^$;$s!%(B

$B$5$i$KFM$C9~$s$@<ALd!’(B
$B!!>e5-(B 2 $B$D$N3d$j9~$_$O!$$3$l$i$N(B API
$B$GCY1d=PMh$J$/$F$b$$$$$b$N$G$7$g$&$+!%(B

$B$5$i$KFM$C9~$s$@<ALd!’(B
$B!!>e5-(B 2 $B$D$N3d$j9~$_$O!$$3$l$i$N(B API
$B$GCY1d=PMh$J$/$F$b$$$$$b$N$G$7$g$&$+!%(B

$BCY1d$G$-$k$N$O(Bmust$B$G$9!#Nc30$N;EAH$$r:FMxM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$@$C$1$H$$$&OC$@$H;W$$$^$9!#8D?ME*$K$ONc30$K$7$F$7$^$&$H$?$V$s2u$l$k%3!<%I$,=P$F$/$k$N$GJQ$($?$/$J$$$J$"!#(B

(2012/06/26 4:51), KOSAKI Motohiro wrote:

$BNc30$@$H0.$j$D$V$;$^$9$1$I!"$=$3$G(B kill

$B$7$?$D$b$j$N%9%l%C%I$,@8$-;D$C$F$7$^$C$FC/$,4r$7$$$s$@$C$1$H$$$&OC$@$H;W$$$^$9!#8D?ME*$K$ONc30$K$7$F$7$^$&$H$?$V$s2u$l$k%3!<%I$,=P$F$/$k$N$GJQ$($?$/$J$$$J$"!#(B

$B!!$=$&$G$9$h$M!%(B1.8 $B$b$=$&$@$7!$$3$3$OJQ$($J$$$H$$$&$3$H$G!%(B

$B1sF#$G$9!#(B

2012/06/26 SASADA Koichi [email protected]:

(2012/06/26 4:51), KOSAKI Motohiro wrote:

$BNc30$@$H0.$j$D$V$;$^$9$1$I!"$=$3$G(B kill

$B$7$?$D$b$j$N%9%l%C%I$,@8$-;D$C$F$7$^$C$FC/$,4r$7$$$s$@$C$1$H$$$&OC$@$H;W$$$^$9!#8D?ME*$K$ONc30$K$7$F$7$^$&$H$?$V$s2u$l$k%3!<%I$,=P$F$/$k$N$GJQ$($?$/$J$$$J$"!#(B

$B!!$=$&$G$9$h$M!%(B1.8 $B$b$=$&$@$7!$$3$3$OJQ$($J$$$H$$$&$3$H$G!%(B

$B$=$NFC<l$J(B Object $B$N0U?^$O$*$=$i$/!V0.$j$D$V$5$l$?$/$J$$!W$@$H(B
$B;W$&$N$G$9$,!"$7$+$7<B:]$K$O(B ensure $B$r;H$($P0.$j$D$V$;$^$9!#(B

th = Thread.new do
begin
begin
sleep 1
ensure
p $!
raise
end
rescue
retry
end
end
sleep 0.5
th.kill

$ ruby t.rb
nil
nil
nil
… ($B7+$jJV$9!"(B^C $B$G;_$a$i$l$J$$(B)

$B$+$H$$$C$F!"$3$N5sF0$rJQ$($k$Y$-$G$O$J$$$H;W$$$^$9!#(B
ensure $B$,<B9T$5$l$J$$$H%j%=!<%9$N%j!<%/$d%G!<%?$N7gB;$,H/@8(B
$B$7$+$M$J$$$H;W$&$N$G!#(B

2012/7/2 Yusuke E. [email protected]:

$B$=$NFC<l$J(B Object $B$N0U?^$O$*$=$i$/!V0.$j$D$V$5$l$?$/$J$$!W$@$H(B
end
nil
… ($B7+$jJV$9!"(B^C $B$G;_$a$i$l$J$$(B)

$B$+$H$$$C$F!"$3$N5sF0$rJQ$($k$Y$-$G$O$J$$$H;W$$$^$9!#(B
ensure $B$,<B9T$5$l$J$$$H%j%=!<%9$N%j!<%/$d%G!<%?$N7gB;$,H/@8(B
$B$7$+$M$J$$$H;W$&$N$G!#(B

$BAG@2$i$7$$F6;!$G$9$M!#$7$+$7$3$N5sF0$O<BAu$r$7$i$J$$$H@dBPA[A|$D$+$J$$$O$:$G!"(B
Thread.kill $B$N%1!<%9$G(B
retry$B$,F0$$$F$7$^$C$F$$$k$N$O%P%0$G$O$J$$$G$7$g$&$+(B

$B$3$l$r5v$9$0$i$$$J$i(BThreadKilledException $B$K;?@.$7$?$/$J$k(B