線程#abort_on_exception():abort_on_exception()是一個線程類方法,該方法返回此“thr”的本地線程“abort on exception”條件的狀態。
用法:Thread.abort_on_exception()
參數:線程值
返回:本地線程“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
相關用法
- Ruby Thread abort_on_exception=用法及代碼示例
- Ruby Thread backtrace_locations()用法及代碼示例
- Ruby Thread alive?用法及代碼示例
- Ruby Thread terminate()用法及代碼示例
- Ruby Thread group()用法及代碼示例
- Ruby Thread add_trace_func用法及代碼示例
- Ruby Thread backtrace用法及代碼示例
- Ruby Thread exit()用法及代碼示例
- Ruby Thread kill()用法及代碼示例
- Ruby Set add?用法及代碼示例
- Ruby Set proper_subset?()用法及代碼示例
注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Thread abort_on_exception function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。