Class GentleThread

java.lang.Object
java.lang.Thread
com.mchange.v1.lang.GentleThread
All Implemented Interfaces:
Runnable

public abstract class GentleThread extends Thread
an abstract Thread class that provides utilities for easily defining Threads with safe versions of the deprecated thread methods stop(), resume(), and start()
  • Constructor Details

    • GentleThread

      public GentleThread()
    • GentleThread

      public GentleThread(String name)
  • Method Details

    • run

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

      public void gentleStop()
      a safe method for stopping properly implemented GentleThreads
    • gentleSuspend

      public void gentleSuspend()
      a safe method for suspending properly implemented GentleThreads
    • gentleResume

      public void gentleResume()
      a safe method for resuming properly implemented GentleThreads
    • shouldStop

      protected boolean shouldStop()
      tests whether the thread should stop. Subclasses should call this method periodically in their run method, and return from run() is the method returns true.
    • shouldSuspend

      protected boolean shouldSuspend()
      tests whether the thread should suspend. Subclasses rarely call this method directly, and should call allowSuspend() periodically instead.
      See Also:
    • allowSuspend

      protected void allowSuspend() throws InterruptedException
      tests whether the thread should suspend, and causes to the thread to pause if appropriate. Subclasses should call this method periodically in their run method to, um, allow suspension. Threads paused by allowSuspend() will be properly awoken by gentleResume()
      Throws:
      InterruptedException
      See Also: