Ruby 线程 add_trace_func函数
Thread#add_trace_func() : add_trace_func() 是Thread类的一个方法,用于添加进程作为追踪的处理程序。
语法。Thread.add_trace_func()
参数。线程值
返回:添加进程作为追踪的处理程序。
例子 #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 : #