Holger's Java API

## com.antelmann.util
Interface ThreadWorker.Listener

All Superinterfaces:
  EventListener

All Known Implementing Classes:
  ThreadWorker.Listener.Adapter

Enclosing class:
  ThreadWorker

    public static interface ThreadWorker.Listener

extends EventListener

listens for tasks run by a ThreadWorker to be finished

Nested Class Summary
`static class` `ThreadWorker.Listener.Adapter`

Method Summary
`void` `prepareTask(Executor executor, Runnable task)` called right before the ThreadWorker starts the given task.
`void` `taskPerformed(Executor executor, Runnable task, long timeTaken, Exception exceptionIfAny)` called after ThreadWorker has finished running the task.

Method Detail

### prepareTask

    void prepareTask(Executor executor,
                     Runnable task)
                     throws CancellationException

  called right before the ThreadWorker starts the given task.

  Throws:
    `CancellationException` - to indicate that this task is not to be executed (all other exceptions thrown are ignored)

### taskPerformed

    void taskPerformed(Executor executor,
                       Runnable task,
                       long timeTaken,
                       Exception exceptionIfAny)

  called after ThreadWorker has finished running the task. The current task is not yet removed from the queue when this method is called. The running thread has ownership over the ThreadWorker when this method is called. Removing a listener in the implementation of this method is allowed.

  Parameters:
    `task` - the task that just finished running
    `timeTaken` - the time (in milliseconds) it took to run the task
    `exceptionIfAny` - if an Exception was thrown during task execution, it will be held by this parameter. This should be null if the task ended normally.

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads