Class ReschedulableTimerTask

java.lang.Object
org.ka2ddo.util.ReschedulableTimerTask
All Implemented Interfaces:
Comparable<ReschedulableTimerTask>, Runnable
Direct Known Subclasses:
FileLogger

public abstract class ReschedulableTimerTask extends Object implements Runnable, Comparable<ReschedulableTimerTask>
This class defines a timer task whose delivery time can be changed while the timer is pending delivery, and can be rescheduled any number of times.
Author:
Andrew Pavlin, KA2DDO
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor for a ReschedulableTimerTask.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Stop running this task, taking it off the pending queue.
    final int
    Test the order of this task relative to other tasks.
    final boolean
    Test if this is the same task instance.
    final int
    Get the hashcode for this object.
    boolean
    Test if this task is actively queued to a timer.
    void
    resched(ReschedulableTimer queue, int delay)
    Queue this task to the specified timer to be executed after the specified period of time.
    void
    resched(ReschedulableTimer queue, int delay, int repeatInterval)
    Queue this task to the specified timer to be executed after the specified period of time.
    void
    resched(ReschedulableTimer queue, Date wakeupTime)
    Queue this task to the specified timer to be executed at the specified time.
    void
    resched(ReschedulableTimer queue, Date wakeupTime, long repeatInterval)
    Queue this task to the specified timer to be executed at the specified time.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Runnable

    run
  • Constructor Details

    • ReschedulableTimerTask

      protected ReschedulableTimerTask()
      Constructor for a ReschedulableTimerTask.
  • Method Details

    • resched

      public void resched(ReschedulableTimer queue, int delay)
      Queue this task to the specified timer to be executed after the specified period of time.
      Parameters:
      queue - ReschedulableTimer to manage this task
      delay - interval in milliseconds before this task should be executed
    • resched

      public void resched(ReschedulableTimer queue, int delay, int repeatInterval)
      Queue this task to the specified timer to be executed after the specified period of time.
      Parameters:
      queue - ReschedulableTimer to manage this task
      delay - interval in milliseconds before this task should be executed
      repeatInterval - time in milliseconds after last scheduled run time that this task should run again
    • resched

      public void resched(ReschedulableTimer queue, Date wakeupTime)
      Queue this task to the specified timer to be executed at the specified time.
      Parameters:
      queue - ReschedulableTimer to manage this task
      wakeupTime - Date object defining the time at which this task should be executed (or as soon after as possible)
    • resched

      public void resched(ReschedulableTimer queue, Date wakeupTime, long repeatInterval)
      Queue this task to the specified timer to be executed at the specified time.
      Parameters:
      queue - ReschedulableTimer to manage this task
      wakeupTime - Date object defining the time at which this task should be executed (or as soon after as possible)
      repeatInterval - time in milliseconds after last scheduled run time that this task should run again
    • cancel

      public void cancel()
      Stop running this task, taking it off the pending queue.
    • compareTo

      public final int compareTo(ReschedulableTimerTask o)
      Test the order of this task relative to other tasks.
      Specified by:
      compareTo in interface Comparable<ReschedulableTimerTask>
      Parameters:
      o - another ReschedulableTimerTask
      Returns:
      -1 if this task is due earlier than the other task, 0 if due at the same time, or +1 if this task is due after the other task
    • equals

      public final boolean equals(Object obj)
      Test if this is the same task instance.
      Overrides:
      equals in class Object
      Parameters:
      obj - some object
      Returns:
      boolean true if it is this object
    • hashCode

      public final int hashCode()
      Get the hashcode for this object.
      Overrides:
      hashCode in class Object
      Returns:
      hashcode
    • isActive

      public boolean isActive()
      Test if this task is actively queued to a timer.
      Returns:
      if this task is scheduled to be executed