From: wanabe Date: 2009-12-31T18:30:32+09:00 Subject: [ruby-core:27354] Re: set_trace_func doesn't allow for differentiation of threads? Hi, 2009/12/31, Roger Pack : > Currently it appears that within a set_trace_func proc, a call to > Thread.current sometimes returns Thread.main, even when that isn't the > "right" current thread. > > (returns 2 in 1.8.x, 1 in 1.9.x): > > all_threads = {} > set_trace_func proc { > all_threads[Thread.current] = true > } > > def go; end > > Thread.new { go }.join # create a new thread after having called > set_trace_func > > puts all_threads.length # should be 2, I think. > > Is this expected? I guess Thread.current is correct, but new-thread is not traced. Because set_trace_func affects only living thread on call it. (please see set_threads_event_flags() in thread.c) I'm afraid I don't know this is expected or not. -- wanabe