Skip to content
Related Articles

Related Articles

Ruby | Thread backtrace_locations() function
  • Last Updated : 09 Dec, 2019

Thread#backtrace_locations() : backtrace_locations() is a Thread class method which returns the execution stack for the target thread—an array containing backtrace location objects.

Syntax: Thread.backtrace_locations()

Parameter: Thread values

Return: the execution stack for the target thread—an array containing backtrace location objects.

Example #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"

Output :

Thread a backtrace_locations() form : []

Example #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"

Output :

Thread a backtrace_locations() form : []

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :