public abstract class AbstractWorker
extends java.lang.Object
The business logic of the Worker is inside the forever()
method. It
is executed by default every getCycleTime()
seconds. Additionally
execution can be triggered by calling the triggerNextRun()
method.
If Cycle-Time is negative (e.g. by using
ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN
) the forever() method is called
only after triggering it.
If Cycle-Time is zero (e.g. by using DO_NOT_WAIT
), the forever()
method is always called immediately without any delay.
Modifier and Type | Field and Description |
---|---|
static int |
ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN |
static int |
DO_NOT_WAIT |
Constructor and Description |
---|
AbstractWorker() |
Modifier and Type | Method and Description |
---|---|
void |
activate(java.lang.String name)
Initializes the worker and starts the worker thread
|
void |
deactivate()
Stops the worker thread
|
protected abstract void |
forever()
This method is called in a loop forever until the Thread gets interrupted.
|
protected abstract int |
getCycleTime()
Gets the cycleTime of this worker in [ms].
|
void |
triggerNextRun()
Allows the next execution of the forever() method.
|
public static final int ALWAYS_WAIT_FOR_TRIGGER_NEXT_RUN
public static final int DO_NOT_WAIT
public void activate(java.lang.String name)
name
- public void deactivate()
protected abstract void forever() throws java.lang.Throwable
java.lang.Throwable
protected abstract int getCycleTime()
public void triggerNextRun()