# Class: com.pnfsoftware.jeb.util.concurrent.ActiveTask

A runnable that can control its own execution. Tasks extending this class must implement the [#runi()](#runi()) method. Client code can [start a task](#start(Runnable)), request cancellation and/or interruption, as well as join for the task to terminate \(either normal termination or a forced termination resulting from a cancel/interrupt request\). 

 This class is similar to some implementation of [futures](Future) \(albeit, its interface is simpler\). The underlying execution primitive \(the thread\) is indirectly accessible via the [#join()](#join()) method; in particular, this class should be used if the client code wants to explicitly join on the underlying thread.

## Constructor: ActiveTask
- parameter: `name`, type: `java.lang.String`

Description: 
parameter: name: task name

## Method: cancel
- return type: `boolean`

Description: Request cancellation and return. The thread is interrupted.
return: true if the thread was alive and has been cancelled

## Method: cancel
- parameter: `interruptThread`, type: `boolean`
- return type: `boolean`

Description: Request cancellation and return.
parameter: interruptThread: true to also interrupt the thread
return: true if the thread was alive and has been cancelled

## Method: interrupt
- return type: `boolean`

Description: Request an interruption of the task's thread. **This method is non blocking**.
return: 

## Method: isCancelled
- return type: `boolean`


## Method: isDone
- return type: `boolean`


## Method: join
- return type: `boolean`


## Method: join
- parameter: `millis`, type: `long`
- return type: `boolean`


## Protected Method: onException
- parameter: `e`, type: `java.lang.Exception`

Description: Executed in async mode only \(in sync mode, exceptions happening during execution are not caught\). The default implementation logs the error and does not rethrow it.
parameter: e: 

## Protected Method: onPostExecution

Description: Executed in sync or async mode. Default implementation does nothing.

## Protected Method: onPreExecution

Description: Executed in sync or async mode. Default implementation does nothing.

## Method: run

Description: Careful not to call when currently executed \(sync or async\).

## Method: runi


## Method: start
- parameter: `completion`, type: `java.lang.Runnable`
- return type: `boolean`

Description: Execute this task on a new daemon thread. If a task has already been started and has not completed, a new task will not be started and instead this method will return false.
parameter: completion: optional runnable that will be executed upon completion, no matter the            outcome \(even if an exception raised\); the execution will take place on the task's            thread
return: true if a new task was started, false otherwise

