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: 2020-03-02 09:10:33 +0100 (mån, 02 mars 2020) $
  • Field Details

    • log

      private static final org.slf4j.Logger log
    • task

      private final TimerTask task
    • allowMultiple

      private final boolean allowMultiple
    • isExecuting

      private boolean isExecuting
  • Constructor Details

    • 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 Details