📜  红宝石 |线程回溯函数

📅  最后修改于: 2022-05-13 01:55:26.684000             🧑  作者: Mango

红宝石 |线程回溯函数

Thread#backtrace() : backtrace()是一个 Thread 类方法,它返回目标线程的当前回溯。

示例 #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