2.17.2: 2011-06-17

net.sf.basedb.util.timer
Class ThreadTimerTask

java.lang.Object
  extended by java.util.TimerTask
      extended by 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) $

Field Summary
private  boolean allowMultiple
           
private  boolean isExecuting
           
private  TimerTask task
           
 
Constructor Summary
ThreadTimerTask(TimerTask task, boolean allowMultiple)
          Create a new threaded timer task.
 
Method Summary
 boolean cancel()
           
 void run()
           
 
Methods inherited from class java.util.TimerTask
scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 fires
allowMultiple - If TRUE, it is allowed to start the same task again before the previous execution has returned, if FALSE the timer event is ignored
Method Detail

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

2.17.2: 2011-06-17