public class ThreadTimerTask extends TimerTask
TimerTask
in
a new thread. Instead of adding the original TimerTask
to a Timer
an instance of this class is added, which
creates a new Thread
where the original TimerTask
:s
run method is executed.
Note that for repeating tasks the use of this class may lead to that the same task is executed again before the previous execution has finished. This may lead to complications if the task is not thread-safe.
Modifier and Type | Field and Description |
---|---|
private boolean |
allowMultiple |
private boolean |
isExecuting |
private TimerTask |
task |
Constructor and Description |
---|
ThreadTimerTask(TimerTask task,
boolean allowMultiple)
Create a new threaded timer task.
|
Modifier and Type | Method and Description |
---|---|
boolean |
cancel() |
void |
run() |
scheduledExecutionTime
private final TimerTask task
private final boolean allowMultiple
private boolean isExecuting
public ThreadTimerTask(TimerTask task, boolean allowMultiple)
task
- The task to execute when the timer firesallowMultiple
- If TRUE, it is allowed to start the same task
again before the previous execution has returned, if FALSE
the timer event is ignored