Ruby | Thread backtrace_locations() function

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 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Thread a backtrace_locations() form : []

Example #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

Thread a backtrace_locations() form : []



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.