Package com.dkt.graphics.utils
Class PThread
java.lang.Object
java.lang.Thread
com.dkt.graphics.utils.PThread
- All Implemented Interfaces:
Runnable
This class basically implements a pausable thread. Please note that
the
pause()
and unpause()
methods won't
release any of the locks the thread might hold, it will simply pause the
thread.- Author:
- Federico Vera <[email protected]>
-
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
-
Method Summary
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
-
PThread
public PThread()
-
-
Method Details
-
pause
public final boolean pause()Pauses the current thread- Returns:
true
if the thread was successfully paused andfalse
if the thread was already paused
-
unpause
public final void unpause()Resumes the current thread -
checkPause
protected final void checkPause()This method should be called within the main run loop. If this isn't called then the thread will not be paused. An example of an implementation could be:class MyThread extends PThread { @Override public void run() { //Init code while(!interrupted() && condition){ checkPause(); //Loop code } //End code } }
-
run
public abstract void run()
-