From: Eric Hodel Date: 2006-05-12T03:08:01+09:00 Subject: Re: Slowing threads On May 11, 2006, at 9:00 AM, Jake McArthur wrote: > Insert the following code somewhere in your main thread: > > class Thread > attr_accessor :execution_speed > end > > def set_execution_speed(seconds_per_line) > Thread.current.execution_speed = seconds_per_line > set_trace_func proc { |event, file, line, id, binding, classname| > if event == "line" and !Thread.current.execution_speed.nil? > sleep Thread.current.execution_speed > end > } > end > > Then, at the beginning of any thread you want slowed down, call the > set_execution_speed method. This will limit the rate that each line > of code in the thread is executed. You can also modify the method > so that it limits based on other criteria such as method calls. set_trace_proc will make your program run much slower than you expect. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com