Skip to content
Related Articles

Related Articles

Ruby | Thread add_trace_func function
  • Last Updated : 09 Dec, 2019
GeeksforGeeks - Summer Carnival Banner

Thread#add_trace_func() : add_trace_func() is a Thread class method which adds process as a handler for tracing.

Syntax: Thread.add_trace_func()

Parameter: Thread values

Return: adds process as a handler for tracing.

Example #1 :






# Ruby code for Thread.add_trace_func() method
  
# declaring Thread 
a = Thread.new { print "a"; Thread.stop; print "c" }
  
prc = lambda {puts 'Hello'}  
  
# add_trace_func form
puts "Thread a add_trace_func() form : #{a.add_trace_func(prc)}\n\n"

Output :

Thread a add_trace_func() form : #

Example #2 :




# Ruby code for Thread.add_trace_func() method
  
# declaring Thread 
a = Thread.new { puts "HI! I am learning to code"}
  
prc = lambda {puts 'Hello'}  
  
# add_trace_func form
puts "Thread a add_trace_func() form : #{a.add_trace_func(prc)}\n\n"

Output :

Thread a add_trace_func() 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 :