From: Joel VanderWerf Date: 2006-03-21T10:50:58+09:00 Subject: Re: Keeping a thread alive Nate Smith wrote: > Hello everyone, > > I'm trying to keep a thread alive after exiting a method. The > pseudo-code is as follows: > > class A > > def start > @mainThread = Thread.new { > oneThread = Thread.new { > # do some stuff > } > twoThread = Thread.new { > # do some other stuff > } > oneThread.join > twoThread.join > } > end > end > > aObject = A.new > aObject.start > > > The problem is that since there is no :join call on @mainThread, it is > killed (and hence oneThread, and twoThread as well) once control ends in > :start. This is perfectly valid, of course, but I would like @mainThread > to stay alive after control in :start ends. Is there any way to do this? > Thanks > > Nate > Is you program exiting after aObject.start? Then maybe you want to do @mainThread.join at that point? The @mainThread should still be alive, until the program exits, unless it has suffered an exception. Do you have Thread.abort_on_exception = true? -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407