Don't forget the state of a thread may also include the set of open 
file handles.   What you are trying to do is called 'checkpointing'.
See e.g. http://en.wikipedia.org/wiki/Application_checkpointing

in the general case, this is _hard_, though there are some packages 
that support this at the application level.

A specific, application aware scheme can be simpler, because you 
presumably know what state must be saved while the general case has to 
assume that all things that make up state must be saved.

Ron.

Patrick Li wrote:
> Thanks for the replies.
> 
> Alright so I have some thoughts now:
> 
> def start
>   status = 0
>   doSomething()
>   status = 1
>   doSomethingElse()
>   status = 2
>   doMore()
>   status = 3
>   cleanup()
> end
> 
> So if I know the status of a thread, (ie. status = 2), and I know the 
> values of the local variables.
> Is there way I can "jump" to that line in the method?
> 
> Amalgalite: I'm not sure if I got your point. It seems to be a SQLite 
> library for Ruby?
> 
> @shadowfirebird: Yes, that's the most straightforward way of doing it. 
> But I'm trying to write a framework that will relieve programmers of 
> having to save state information manually.
> 
> ie. I'm trying to convert this:
> 
> stateVar = 124
> def update
>   if(stateVar == 0) then doStuff(); stateVar = 1
>   if(stateVar == 1) then doMoreStuff(); stateVar = 2
>   if(stateVar == 2) then cleanup(); stateVar = 3
> end
> 
> Into This:
> 
> start
> doStuff()
> doMoreStuff()
> doEvenMore()
> cleanup()
> endProgram()


-- 
Ron Fox
NSCL
Michigan State University
East Lansing, MI 48824-1321