Package org.oscim.utils
Class PausableThread
java.lang.Object
java.lang.Thread
org.oscim.utils.PausableThread
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
TileLoader
An abstract base class for threads which support pausing and resuming.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled once when this thread continues to work after a pause.protected voidafterRun()Called once at the end of therun()method.final voidCauses the current thread to wait until this thread is pausing.protected abstract voiddoWork()Called when this thread is not paused and should do its work.voidfinish()protected abstract Stringprotected intprotected abstract booleanhasWork()final booleanfinal booleanfinal voidpause()The thread should stop its work temporarily.final voidproceed()The paused thread should continue with its work.final voidrun()Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
PausableThread
public PausableThread()
-
-
Method Details
-
awaitPausing
public final void awaitPausing()Causes the current thread to wait until this thread is pausing. -
finish
public void finish() -
isPausing
public final boolean isPausing()- Returns:
- true if this thread is currently pausing, false otherwise.
-
pause
public final void pause()The thread should stop its work temporarily. -
proceed
public final void proceed()The paused thread should continue with its work. -
isCanceled
public final boolean isCanceled() -
run
public final void run() -
afterPause
protected void afterPause()Called once when this thread continues to work after a pause. The default implementation is empty. -
afterRun
protected void afterRun()Called once at the end of therun()method. The default implementation is empty. -
doWork
Called when this thread is not paused and should do its work.- Throws:
InterruptedException- if the thread has been interrupted.
-
getThreadName
- Returns:
- the name of this thread.
-
getThreadPriority
protected int getThreadPriority()- Returns:
- the priority of this thread. The default value is
Thread.NORM_PRIORITY.
-
hasWork
protected abstract boolean hasWork()- Returns:
- true if this thread has some work to do, false otherwise.
-