Package org.mapsforge.map.util
Class PausableThread
- java.lang.Object
-
- java.lang.Thread
-
- org.mapsforge.map.util.PausableThread
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
LayerManager
public abstract class PausableThread extends java.lang.ThreadAn abstract base class for threads which support pausing and resuming.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPausableThread.ThreadPrioritySpecifies the scheduling priority of aThread.
-
Field Summary
Fields Modifier and Type Field Description protected booleanwaitForWork
-
Constructor Summary
Constructors Constructor Description PausableThread()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidafterRun()Called once at the end of therun()method.voidawaitPausing()Causes 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 PausableThread.ThreadPrioritygetThreadPriority()protected abstract booleanhasWork()voidinterrupt()booleanisPausing()voidpause()The thread should stop its work temporarily.voidproceed()The paused thread should continue with its work.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, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Method Detail
-
awaitPausing
public final void awaitPausing()
Causes the current thread to wait until this thread is pausing.
-
finish
public final void finish()
-
interrupt
public void interrupt()
- Overrides:
interruptin classjava.lang.Thread
-
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.
-
run
public final void run()
- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
afterRun
protected void afterRun()
Called once at the end of therun()method. The default implementation is empty.
-
doWork
protected abstract void doWork() throws java.lang.InterruptedExceptionCalled when this thread is not paused and should do its work.- Throws:
java.lang.InterruptedException- if the thread has been interrupted.
-
getThreadPriority
protected abstract PausableThread.ThreadPriority getThreadPriority()
- Returns:
- the priority which will be set for this thread.
-
hasWork
protected abstract boolean hasWork()
- Returns:
- true if this thread has some work to do, false otherwise.
-
-