红宝石 |线程 add_trace_func函数
Thread#add_trace_func() : add_trace_func()是一个 Thread 类方法,它添加进程作为跟踪的处理程序。
Syntax: Thread.add_trace_func()
Parameter: Thread values
Return: adds process as a handler for tracing.
示例 #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"
输出 :
Thread a add_trace_func() form : #
示例 #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"
输出 :
Thread a add_trace_func() form : #