statalign.base.thread
Class Stoppable

java.lang.Object
  extended by statalign.base.thread.Stoppable
Direct Known Subclasses:
Mcmc, Tree, TreeAlgo

public abstract class Stoppable
extends java.lang.Object

Ancestor for classes that can define potential "stopping points" in (some of) their methods when called from within a StoppableThread. A StoppableThread can be safely stopped by another thread when execution reaches such a point. "Pausing points" can also be defined to allow the StoppableThread to be paused at certain points.

Author:
novak

Constructor Summary
Stoppable()
          Default constructor.
 
Method Summary
 void pausable()
          Should be called from methods of the descendant classes at points where execution is allowed to be suspended by an external thread (by calling the StoppableThread's suspendSoft() method) If the descendant object has not been created from within a StoppableThread, calling this method has no effect.
 void stoppable()
          Should be called from methods of the descendant classes at points where execution is allowed to be stopped by an external thread (by calling the StoppableThread's stopSoft() method) If this happens, a StoppedException is thrown that can be caught at any point within the StoppableThread to do things up before exiting.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Stoppable

public Stoppable()
Default constructor. Finds out if the object has been created from within a StoppableThread.

Method Detail

pausable

public void pausable()
Should be called from methods of the descendant classes at points where execution is allowed to be suspended by an external thread (by calling the StoppableThread's suspendSoft() method) If the descendant object has not been created from within a StoppableThread, calling this method has no effect.


stoppable

public void stoppable()
               throws StoppedException
Should be called from methods of the descendant classes at points where execution is allowed to be stopped by an external thread (by calling the StoppableThread's stopSoft() method) If this happens, a StoppedException is thrown that can be caught at any point within the StoppableThread to do things up before exiting. If the descendant object has not been created from within a StoppableThread, calling this method has no effect.

Throws:
StoppedException - When stopping the execution of the StoppableThread has been requested via stopSoft()