Class ServiceThread

java.lang.Object
java.lang.Thread
gaiasky.util.concurrent.ServiceThread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
OctreeLoader.OctreeLoaderThread, OrbitRefresher.OrbitUpdaterThread

public class ServiceThread extends Thread
A thread that waits for a task to be executed. Tasks can be aborted.
  • Field Details

  • Constructor Details

    • ServiceThread

      public ServiceThread()
    • ServiceThread

      public ServiceThread(String name)
  • Method Details

    • getThreadLock

      public Object 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

      public void offerTask(Runnable task)
      This method 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.
    • wakeUp

      public void wakeUp()
      This method wakes up the thread and runs the current task. If the thread is sleeping, the task is executed right away. Otherwise, the method blocks and does a busy wait until the current task finishes.
    • waitCurrentTask

      public void waitCurrentTask()
      This method does an active wait until the current task is finished. If no task is executed, this returns immediately.
    • run

      public void run()
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread