當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Ruby Thread backtrace_locations()用法及代碼示例


線程#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 : []



相關用法


注:本文由純淨天空篩選整理自mayank5326大神的英文原創作品 Ruby | Thread backtrace_locations() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。