|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
statalign.base.thread.StoppableThread
public class StoppableThread
Objects of this class can be used in place of a Thread object if it is intended that
they can be stopped or suspended "softly" by an external thread. This means that if an
external thread requests termination of this thread (by calling stopSoft()),
execution will continue up to the first "stopping point", i.e. the first call of
stoppable() from within this thread.
At this point, a StoppedException will be thrown, and the StoppableThread will be given
the chance to catch it at an arbitrary point and do up before termination.
In every other aspect, a StoppableThread is like a Thread, e.g. you should override
run() and place your "softly stoppable" code there. But you must declare your run()
method synchronized
for most of the above to work properly.
The easiest way to define "stopping points" and "pausing points" in your own classes
is to use Stoppable as the ancestor and call its stoppable() and pausable() methods from
your methods.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary |
---|
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
StoppableThread()
|
Method Summary | |
---|---|
void |
pauseNoWait()
Can be called by an external thread to request suspension of this thread. |
void |
pauseToggleSoft()
Calls suspendSoft() or resumeSoft(), depending on the current state of this thread. |
void |
resumeSoft()
Resumes execution of this thread if it has been previously paused by pauseSoft(). |
void |
stopNoWait()
Similar to stopSoft() but non-blocking, and also will not wake up this thread if it is suspended. |
void |
stopSoft()
Can be called by an external thread to request termination of this thread. |
void |
suspendSoft()
Can be called by an external thread to request suspension of this thread. |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public StoppableThread()
Method Detail |
---|
public void suspendSoft()
public void pauseToggleSoft()
public void pauseNoWait()
public void resumeSoft()
public void stopSoft()
public void stopNoWait()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |