红宝石 |线程 abort_on_exception=函数
Thread#abort_on_exception=() : abort_on_exception=()是一个 Thread 类方法,它将引发的异常设置为 true 或 false
Syntax: Thread.abort_on_exception=()
Parameter: Thread values
Return: sets the raised exception to true or 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=true}\n\n"
输出 :
Thread a abort_on_exception=() form : true
示例 #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=false}\n\n"
输出 :
Thread a abort_on_exception=() form : false