📜  红宝石 |线程 backtrace_locations()函数

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

红宝石 |线程 backtrace_locations()函数

Thread#backtrace_locations() : backtrace_locations()是一个 Thread 类方法,它返回目标线程的执行堆栈——一个包含回溯位置对象的数组。

示例 #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 : []