Class PThread

  • All Implemented Interfaces:

    public abstract class PThread
    extends java.lang.Thread
    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.
    • 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

    • Constructor Summary

      Constructor Description
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void checkPause()
      This method should be called within the main run loop.
      boolean pause()
      Pauses the current thread
      abstract void run()  
      void unpause()
      Resumes the current thread
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • 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, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
    • Constructor Detail

      • PThread

        public PThread()
    • Method Detail

      • pause

        public final boolean pause()
        Pauses the current thread
        true if the thread was successfully paused and false 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 {
                  public void run() {
                      //Init code
                      while(!interrupted() && condition){
                           //Loop code
                      //End code
      • run

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