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 a 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.
- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2008-09-11 22:08:14 +0200 (Thu, 11 Sep 2008) $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
task
private final TimerTask task
allowMultiple
private final boolean allowMultiple
isExecuting
private boolean isExecuting
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
run
public final void run()
- Specified by:
run
in interface Runnable
- Specified by:
run
in class TimerTask
cancel
public boolean cancel()
- Overrides:
cancel
in class TimerTask