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.Thread
An abstract base class for threads which support pausing and resuming.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
PausableThread.ThreadPriority
Specifies the scheduling priority of aThread
.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
waitForWork
-
Constructor Summary
Constructors Constructor Description PausableThread()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
afterRun()
Called once at the end of therun()
method.void
awaitPausing()
Causes the current thread to wait until this thread is pausing.protected abstract void
doWork()
Called when this thread is not paused and should do its work.void
finish()
protected abstract PausableThread.ThreadPriority
getThreadPriority()
protected abstract boolean
hasWork()
void
interrupt()
boolean
isPausing()
void
pause()
The thread should stop its work temporarily.void
proceed()
The paused thread should continue with its work.void
run()
-
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:
interrupt
in 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:
run
in interfacejava.lang.Runnable
- Overrides:
run
in 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.InterruptedException
Called 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.
-
-