Class CancellableThread

java.lang.Object
java.lang.Thread
com.xinapse.util.CancellableThread
All Implemented Interfaces:
Runnable

public abstract class CancellableThread extends Thread
A class to implement a cancellable Thread. Thread cancellation is achieved by setting the flag. It is up to the thread's run method to check this flag periodically and return if set.
  • Field Details

    • CANCELLED_MESSAGE

      public static final String CANCELLED_MESSAGE
      A String used to report cancellation.
      See Also:
    • INTERRUPTED_MESSAGE

      public static final String INTERRUPTED_MESSAGE
      A String used to report interruption.
      See Also:
    • UNEXPECTED_CANCELLATION_MESSAGE

      public static final String UNEXPECTED_CANCELLATION_MESSAGE
      A String used to report unexpected cancellation.
      See Also:
  • Method Details

    • run

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

      public void cancel()
      Signal the CancellableThread to stop any processing and return.
    • isCancelled

      public boolean isCancelled()
      Tests whether this CancellableThread has been cancelled.
      Returns:
      true if this CancellableThread has been cancelled by the user; false otherwise.