Ruby 线程 abort_on_exception函数
Thread#abort_on_exception() : abort_on_exception() 是Thread类的一个方法,用于返回该 “three “的线程本地 “异常时终止 “条件的状态。
语法。Thread.abort_on_exception()
参数。线程值
返回。线程本地的 “异常时终止 “的状态
默认 – 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