Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Ruby | Thread backtrace function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Thread#backtrace() : backtrace() is a Thread class method which returns the current backtrace of the target thread.

Syntax: Thread.backtrace()

Parameter: Thread values

Return: the current backtrace of the target thread.

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

Output :

Thread a backtrace() form : []

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

Output :

Thread a backtrace() form : []

HI! I am learning to code
My Personal Notes arrow_drop_up
Last Updated : 09 Dec, 2019
Like Article
Save Article
Similar Reads