Package org.ka2ddo.util
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
ModifierConstructorDescriptionprotected
Constructor for a ReschedulableTimerTask. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
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
hashCode()
Get the hashcode for this object.boolean
isActive()
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.
-
Constructor Details
-
ReschedulableTimerTask
protected ReschedulableTimerTask()Constructor for a ReschedulableTimerTask.
-
-
Method Details
-
resched
Queue this task to the specified timer to be executed after the specified period of time.- Parameters:
queue
- ReschedulableTimer to manage this taskdelay
- interval in milliseconds before this task should be executed
-
resched
Queue this task to the specified timer to be executed after the specified period of time.- Parameters:
queue
- ReschedulableTimer to manage this taskdelay
- interval in milliseconds before this task should be executedrepeatInterval
- time in milliseconds after last scheduled run time that this task should run again
-
resched
Queue this task to the specified timer to be executed at the specified time.- Parameters:
queue
- ReschedulableTimer to manage this taskwakeupTime
- Date object defining the time at which this task should be executed (or as soon after as possible)
-
resched
Queue this task to the specified timer to be executed at the specified time.- Parameters:
queue
- ReschedulableTimer to manage this taskwakeupTime
- 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
Test the order of this task relative to other tasks.- Specified by:
compareTo
in interfaceComparable<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
Test if this is the same task instance. -
hashCode
public final int hashCode()Get the hashcode for this object. -
isActive
public boolean isActive()Test if this task is actively queued to a timer.- Returns:
- if this task is scheduled to be executed
-