de.esprit.common.concurrent

## Class CancellableThread

- java.lang.Object
- - java.lang.Thread
  - - de.esprit.common.concurrent.CancellableThread

- All Implemented Interfaces:
    Cancellable, java.lang.Runnable
  Direct Known Subclasses:
    AbstractOneShotTimer

      public class CancellableThread
      extends java.lang.Thread
      implements Cancellable

  This is a cancellable thread which manages a cancel flag internally. In order to work correctly the run() implementation must use the isCancelled() method in order to check if the thread has been cancelled.
  Author:
    Rainer Buesch

- - ### 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 and Description
    `CancellableThread()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()` Sets the cancel flag within this thread
    `void` | `checkCancelled()`
    `java.lang.String` | `toString()`
    `ToString` | `toString(ToString s)`
    `boolean` | `wasCancelled()` Checks whether the cancel flag has been set

    - ### 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, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### CancellableThread

          public CancellableThread()

  - ### Method Detail

    - #### checkCancelled

          public void checkCancelled()

    - #### cancel

          public void cancel()

      Sets the cancel flag within this thread
      Specified by:
        `cancel` in interface `Cancellable`

    - #### wasCancelled

          public boolean wasCancelled()

      Checks whether the cancel flag has been set
      Specified by:
        `wasCancelled` in interface `Cancellable`

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Thread`

    - #### toString

          public ToString toString(ToString s)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.