Package net.sf.basedb.util.timer
Class ThreadTimerTask
- java.lang.Object
-
- java.util.TimerTask
-
- net.sf.basedb.util.timer.ThreadTimerTask
-
- All Implemented Interfaces:
Runnable
public class ThreadTimerTask extends TimerTask
Class for forcing the execution of aTimerTask
in a new thread. Instead of adding the originalTimerTask
to aTimer
an instance of this class is added, which creates a newThread
where the originalTimerTask
: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.
- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2015-01-14 14:29:04 +0100 (on, 14 jan 2015) $
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
allowMultiple
private boolean
isExecuting
private TimerTask
task
-
Constructor Summary
Constructors Constructor Description ThreadTimerTask(TimerTask task, boolean allowMultiple)
Create a new threaded timer task.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cancel()
void
run()
-
Methods inherited from class java.util.TimerTask
scheduledExecutionTime
-
-
-
-
Field Detail
-
task
private final TimerTask task
-
allowMultiple
private final boolean allowMultiple
-
isExecuting
private boolean isExecuting
-
-
Constructor Detail
-
ThreadTimerTask
public ThreadTimerTask(TimerTask task, boolean allowMultiple)
Create a new threaded timer task. The task is executed in a new thread.- Parameters:
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
-
-