Ruby 线程 backtrace函数
Thread#backtrace() : backtrace()是Thread类的一个方法,用于返回目标线程的当前回溯。
语法。Thread.backtrace()
参数。线程值
返回:目标线程的当前回溯。
例子 #1 :
# Ruby code for Thread.backtrace() method
# declaring Thread
a = Thread.new { print "a"; Thread.stop; print "c" }
# backtrace form
puts "Thread a backtrace() form : #{a.backtrace()}\n\n"
输出:
Thread a backtrace() form : []
例子 #2 :
# Ruby code for Thread.backtrace() method
# declaring Thread
a = Thread.new { puts "HI! I am learning to code"}
# backtrace form
puts "Thread a backtrace() form : #{a.backtrace()}\n\n"
输出:
Thread a backtrace() form : []
HI! I am learning to code