Ruby 线程 backtrace_locations() 函数
Thread#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 : []