From: Brian Candler Date: 2009-12-16T23:22:47+09:00 Subject: Re: Using threads to show progress Aldric Giacomoni wrote: > I now have this code going for me : 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. > It has a couple of > 'each' statements, so I will probably end up needing to call a > 'printing' thread a few times, once for each step -- that is why I can't > just use the main thread to print.. Can you not just do $stderr.puts ... ? 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. 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. -- Posted via http://www.ruby-forum.com/.