From: Eric Hodel Date: 2009-05-31T04:02:42+09:00 Subject: Re: Runnin code at a certain time? On May 30, 2009, at 12:46, Caleb Clausen wrote: > On 5/30/09, Eric Hodel wrote: >>> Is there some particular danger that Thread#run will be called on my >>> threads without my asking? >> >> If it's library code, yes. If it's application code, probably not. > > Can you be more specific? I'm curious as to how exactly this could > happen. I suspect you speak from experience, but I can't see how if an > application fiddles with a libraries internals in this way, that's not > considered a bug in the application. Since threads are involved, it doesn't need to muck with any internals, it just has to wake up the thread your sleep was running in: class YourLib def your_sleep sleep 1_000_000 end end class MyApp # ... def do_stuff @threads << Thread.start do # ... YourLib.new.your_sleep # ... end end def wakeup @threads.each do |thread| thread.run end end end