org.jfree.report.util

## Class Worker

- java.lang.Object
- - java.lang.Thread
  - - org.jfree.report.util.Worker

- All Implemented Interfaces:
    java.lang.Runnable

      public final class Worker
      extends java.lang.Thread

  A simple worker implementation. The worker executes a assigned workload and then sleeps until another workload is set or the worker is killed.
  Author:
    Thomas Morgner

- - ### 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
    `Worker()` Creates a new worker.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `finish()` Kills the worker after he completed his work.
    `WorkerPool` | `getWorkerPool()` Returns the worker's assigned pool.
    `java.lang.Runnable` | `getWorkload()` Returns the workload object.
    `boolean` | `isAvailable()` Checks, whether this worker has some work to do.
    `boolean` | `isFinish()` Checks whether this worker has received the signal to finish and die.
    `void` | `run()` If a workload is set, process it.
    `void` | `setWorkerPool(WorkerPool workerPool)` Defines the worker's assigned pool.
    `void` | `setWorkload(java.lang.Runnable r)` Set the next workload for this worker.

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

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

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

- - ### Constructor Detail

    - #### Worker

          public Worker()

      Creates a new worker.

  - ### Method Detail

    - #### setWorkload

          public void setWorkload(java.lang.Runnable r)

      Set the next workload for this worker.
      Parameters:
        `r` - the next workload for the worker.
      Throws:
        `java.lang.IllegalStateException` - if the worker is not idle.

    - #### getWorkload

          public java.lang.Runnable getWorkload()

      Returns the workload object.
      Returns:
        the runnable executed by this worker thread.

    - #### finish

          public void finish()

      Kills the worker after he completed his work. Awakens the worker if he's sleeping, so that the worker dies without delay.

    - #### isAvailable

          public boolean isAvailable()

      Checks, whether this worker has some work to do.
      Returns:
        true, if this worker has no more work and is currently sleeping.

    - #### run

          public void run()

      If a workload is set, process it. After the workload is processed, this worker starts to sleep until a new workload is set for the worker or the worker got the finish() request.
      Specified by:
        `run` in interface `java.lang.Runnable`
      Overrides:
        `run` in class `java.lang.Thread`

    - #### isFinish

          public boolean isFinish()

      Checks whether this worker has received the signal to finish and die.
      Returns:
        true, if the worker should finish the work and end the thread.

    - #### getWorkerPool

          public WorkerPool getWorkerPool()

      Returns the worker's assigned pool.
      Returns:
        the worker pool (or null, if the worker is not assigned to a pool).

    - #### setWorkerPool

          public void setWorkerPool(WorkerPool workerPool)

      Defines the worker's assigned pool.
      Parameters:
        `workerPool` - the worker pool (or null, if the worker is not assigned to a pool).