Class 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 a Thread.
      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean waitForWork  
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • 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 the run() 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • waitForWork

        protected boolean waitForWork
    • Constructor Detail

      • PausableThread

        public PausableThread()
    • 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 class java.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 interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • afterRun

        protected void afterRun()
        Called once at the end of the run() 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.