| |
|
| java.lang.Object java.lang.Thread org.jfree.report.util.Worker
Worker | final public class Worker extends Thread (Code) | | 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 |
Constructor Summary | |
public | Worker() Creates a new worker. |
Method Summary | |
public void | finish() Kills the worker after he completed his work. | public WorkerPool | getWorkerPool() Returns the worker's assigned pool. | public synchronized Runnable | getWorkload() Returns the workload object. | public boolean | isAvailable() Checks, whether this worker has some work to do. | public boolean | isFinish() Checks whether this worker has received the signal to finish and die. | public synchronized void | run() If a workload is set, process it. | public void | setWorkerPool(WorkerPool workerPool) Defines the worker's assigned pool. | public void | setWorkload(Runnable r) Set the next workload for this worker. |
Worker | public Worker()(Code) | | Creates a new worker.
Parameters: sleeptime - the time this worker sleeps until he checks for new work. |
finish | public void finish()(Code) | | Kills the worker after he completed his work. Awakens the worker if he's sleeping, so
that the worker dies without delay.
|
getWorkerPool | public WorkerPool getWorkerPool()(Code) | | Returns the worker's assigned pool.
the worker pool (or null, if the worker is not assigned to a pool). |
getWorkload | public synchronized Runnable getWorkload()(Code) | | Returns the workload object.
the runnable executed by this worker thread. |
isAvailable | public boolean isAvailable()(Code) | | Checks, whether this worker has some work to do.
true, if this worker has no more work and is currently sleeping. |
isFinish | public boolean isFinish()(Code) | | Checks whether this worker has received the signal to finish and die.
true, if the worker should finish the work and end the thread. |
run | public synchronized void run()(Code) | | 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.
|
setWorkerPool | public void setWorkerPool(WorkerPool workerPool)(Code) | | Defines the worker's assigned pool.
Parameters: workerPool - the worker pool (or null, if the worker is not assigned to apool). |
setWorkload | public void setWorkload(Runnable r)(Code) | | Set the next workload for this worker.
Parameters: r - the next workload for the worker. throws: IllegalStateException - if the worker is not idle. |
|
|
|