Class PauseableThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class PauseableThread
    extends java.lang.Thread
    A pausable thread. The runnable must not execute an infinite loop but should return control to the thread as often as possible so that the thread can actually pause.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

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

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor Description
      PauseableThread​(java.lang.Runnable runnable)
      Constructs a new thread setting the runnable which will be called repeatedly in a loop.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isPaused()  
      void onPause()
      Pauses the thread.
      void onResume()
      Resumes the thread.
      void run()  
      void stopThread()
      Stops this thread
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

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

      • PauseableThread

        public PauseableThread​(java.lang.Runnable runnable)
        Constructs a new thread setting the runnable which will be called repeatedly in a loop.
        Parameters:
        runnable - the runnable.
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
      • onPause

        public void onPause()
        Pauses the thread. This call is non-blocking
      • onResume

        public void onResume()
        Resumes the thread. This call is non-blocking
      • isPaused

        public boolean isPaused()
        Returns:
        whether this thread is paused or not
      • stopThread

        public void stopThread()
        Stops this thread