Package gaiasky.util.concurrent
Class ServiceThread
java.lang.Object
java.lang.Thread
gaiasky.util.concurrent.ServiceThread
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
StreamingOctreeLoader.OctreeLoaderThread
A thread that waits for a task to be executed. Tasks can
be aborted.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected Runnable
protected Object
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
-
Field Details
-
task
-
threadLock
-
awake
protected boolean awake -
running
protected boolean running
-
-
Constructor Details
-
ServiceThread
public ServiceThread() -
ServiceThread
-
-
Method Details
-
getThreadLock
-
isRunning
public boolean isRunning()Whether the thread is running or it is stopped.- Returns:
- The running state.
-
stopDaemon
public void stopDaemon()Stops the daemon iterations when the current task has finished. -
isAwake
public boolean isAwake()Queries the thread state.- Returns:
- True if the thread is currently running stuff, false otherwise.
-
offerTask
This methods offers the new task to the service thread. If the thread is sleeping, the new task is set and executed right away. Otherwise, the method blocks and does a busy wait until the current task finishes.- Parameters:
task
- The new task to run.
-
run
public void run()
-