public class WorkerThread
extends java.lang.Object
Users of the object do have control on how often the work happens and if there is an sleep between intervals at all.
They also have explicity control to start and stop the work in a separate thread.
| Modifier and Type | Class and Description |
|---|---|
static class |
WorkerThread.UnitTest |
static interface |
WorkerThread.Worker
Interface for the functionality of a worker object
|
| Constructor and Description |
|---|
WorkerThread(WorkerThread.Worker worker) |
WorkerThread(WorkerThread.Worker worker,
boolean sleep) |
WorkerThread(WorkerThread.Worker worker,
int sleepMillis) |
WorkerThread(WorkerThread.Worker worker,
int sleepMillis,
boolean sleep) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isRunning()
Helper to identify if worker is still running
|
boolean |
isStopRequested()
Helper to identify is work has been requested to stop
|
void |
start()
Start the work, must happen once and only once.
|
void |
stop()
Request worker to stop
|
void |
stopAndBlock()
Stop and block till worker is finished
|
public WorkerThread(WorkerThread.Worker worker)
worker - public WorkerThread(WorkerThread.Worker worker, boolean sleep)
worker - sleep - public WorkerThread(WorkerThread.Worker worker, int sleepMillis)
worker - sleepMillis - public WorkerThread(WorkerThread.Worker worker, int sleepMillis, boolean sleep)
worker - sleepMillis - sleep - public void start()
throws java.lang.Exception
java.lang.Exceptionpublic void stop()
public void stopAndBlock()
public boolean isRunning()
public boolean isStopRequested()