From: Aldric Giacomoni Date: 2009-12-17T00:09:15+09:00 Subject: Re: Using threads to show progress Brian Candler wrote: > > Killing threads asynchronously is usually a Bad Idea[TM]. It leaves you > open to all sorts of race conditions. Terminating gracefully, by sending > a nil into the queue as I showed before, is much better. I read the rdocs for the Queue class and now I understand how it works - you are right, I will fix my ugly code. > > The main downside of this is if you are processing 10,000,000 things and > you don't want 10,000,000 screen updates. In that case, I suggest you > keep a "last output" timestamp and only update once per second. That is a good idea! > > Another option might be to take advantage of duck-typing. Replace > $stderr with an object of your own which looks like an IO, but which > only writes the data if no update has been seen for the last second, or > something like that. That sounds like work. *shudder* On the other hand, that's a great way to start playing with IO objects. -- Posted via http://www.ruby-forum.com/.