[kepler-dev] Can "stop" interrupt "initialize()"

Kevin Ruland kruland at ku.edu
Tue Jan 31 04:56:03 PST 2006


Edward A. Lee wrote:
> At 01:49 PM 1/30/2006 -0600, Kevin Ruland wrote:
>
>>> Every Director has a method isStopRequested().
>>> A long running initialize() method should just call this method
>>> and abort if it returns true...
>>
>> I think I can use this in some kind of spin wait.  What's the easiest 
>> way for an actor get a handle to it's director?
>
>  Call getDirector().
>  I wouldn't do this as a spin wait, though. Instead,
>  in the long running thread, periodically call isStopRequested() at
>  points where it would be safe to abort.  This is much safer than
>  calling interrupt() on a thread, which can leave objects in an
>  undefined state.
>

Unfortunately, the long running process is a soap download and there 
aren't any convenient places to insert the tests (ie it's all messy axis 
generated code).  Currently my only synchronization mechanism is a 
CountDown (from oswego) on which I can block until it becomes 0.  So 
really I need to poll both the CountDown and the isStopRequested() - or 
I need to hang on to a reference to the thread blocking on the 
CountDown, then interrupt it in the actor stop() method.

BTW - Thread.interrupt() is fine.  It's Thread.stop() which is 
deprecated because of object consistency problems.  Thread.interrupt() 
will make blocking i/o and Thread.wait() throw InterruptedExceptions, 
and otherwise it only sets a flag isInterrupted() flag on the Thread.

Thanks for the help.

Kevin



More information about the Kepler-dev mailing list