From: "Iñaki Baz Castillo" Date: 2008-08-23T00:45:57+09:00 Subject: Re: Saving the state of a Thread? El Viernes, 22 de Agosto de 2008, Patrick Li escribió: > Mmm, that's not quite it. > > Here's an example: > > eg. > def start > initialize() > doSomething() > doSomethingElse() <-- Three hours into processing > doMore() > cleanup() > end > > so imagine this method is called inside a Thread. And three hours into > processing, the user wants to take a break and save his progress to > disk. > > Next time the program starts up, I want to be able to jump directly to > the > doSomethingElse() line. With the appropriate local variables all set and > ready. > > Is this possible? Using thread variables you could do: def initialize @thread = Thread.current end def doSomething() @thread[:state] = 'doSomething' end def doSomethingElse() @thread[:state] = 'doSomethingElse' end def start initialize() doSomething() doSomethingElse() <-- Three hours into processing doMore() cleanup() end -- Iñaki Baz Castillo