From: Mike Houghton Date: 2006-11-17T01:09:34+09:00 Subject: Re: Threading Question Phlip wrote: > Mike Houghton wrote: > >> I'm new (very new!) to Ruby but not to programming. I have a >> Thread/class inheritance question.I'm trying to make a simple timer >> class that extends Thread and repeats a block times and each >> repetition separated by seconds. Here's the code > > Are you coming from Java? It sets a bad example for threading. Don't use > it > just for conveniences > > Here's an example how Ruby does thready things without the risk and > complexity of threads in your own code: > > require 'timeout' > status = Timeout::timeout(5) { > # Something that should be interrupted if it takes too much time... > } > > Look up Timeout, and it might do what you need, or lead to a similar > technique. Thanks for the comments. I looked at Timeout and, though it could be used here, I think its for something more imperative than running a block every n seconds and besides the block might not terminate before the timeout. -- Posted via http://www.ruby-forum.com/.