Class 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: 2015-01-14 14:29:04 +0100 (on, 14 jan 2015) $
    • Field Detail

      • 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