线程#backtrace_locations():backtrace_locations()是一个Thread类方法,它返回目标线程的执行堆栈-包含回溯位置对象的数组。
用法:Thread.backtrace_locations()
参数:线程值
返回:目标线程的执行堆栈-包含回溯位置对象的数组。
示例1:
# Ruby code for Thread.backtrace_locations() method
# declaring Thread
a = Thread.new { print "a"; Thread.stop; print "c" }
# backtrace_locations form
puts "Thread a backtrace_locations() form : #{a.backtrace_locations()}\n\n"
输出:
Thread a backtrace_locations() form : []
示例2:
# Ruby code for Thread.backtrace_locations() method
# declaring Thread
a = Thread.new { puts "HI! I am learning to code"}
# backtrace_locations form
puts "Thread a backtrace_locations() form : #{a.backtrace_locations()}\n\n"
输出:
Thread a backtrace_locations() form : []
相关用法
- Ruby Thread terminate()用法及代码示例
- Ruby Thread backtrace用法及代码示例
- Ruby Thread exit()用法及代码示例
- Ruby Thread kill()用法及代码示例
- Ruby Thread add_trace_func用法及代码示例
- Ruby Thread group()用法及代码示例
- Ruby Thread alive?用法及代码示例
- Ruby Thread abort_on_exception用法及代码示例
- Ruby Thread abort_on_exception=用法及代码示例
- Ruby Set add?用法及代码示例
注:本文由纯净天空筛选整理自mayank5326大神的英文原创作品 Ruby | Thread backtrace_locations() function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。