红宝石 |线程 abort_on_exception函数
Thread#abort_on_exception() : abort_on_exception()是一个 Thread 类方法,它返回此“thr”的线程本地“异常中止”条件的状态。
Syntax: Thread.abort_on_exception()
Parameter: Thread values
Return: The status of the thread-local “abort on exception”
Default – False
示例 #1:
# Ruby code for Thread.abort_on_exception() method
# declaring Thread
a = Thread.new { print "a"; Thread.stop; print "c" }
# abort_on_exception form
puts "Thread a abort_on_exception() form : #{a.abort_on_exception()}\n\n"
输出 :
Thread a abort_on_exception() form : false
示例 #2:
# Ruby code for Thread.abort_on_exception() method
# declaring Thread
a = Thread.new { puts "HI! I am learning to code"}
# abort_on_exception form
puts "Thread a abort_on_exception() form : #{a.abort_on_exception()}\n\n"
输出 :
Thread a abort_on_exception() form : false
=> nilHI! I am learning to code