Methods Summary |
---|
public boolean | cancel()Cancel the execution of the task. Return true if it was actually
running, or false if it was already cancelled or never scheduled.
if (cancelled) return false; // Already cancelled;
cancelled = true; // Cancel it
if (nextTime == -1) return false; // Never scheduled;
return true;
|
boolean | reschedule()
if (period == 0 || cancelled) return false; // Don't run it again
if (fixedRate) nextTime += period;
else nextTime = System.currentTimeMillis() + period;
return true;
|
public abstract void | run()Subclasses must override this to provide that code that is to be run.
The Timer class will invoke this from its internal thread.
|
void | schedule(long nextTime, long period, boolean fixedRate)
this.nextTime = nextTime;
this.period = period;
this.fixedRate = fixedRate;
|
public long | scheduledExecutionTime()When it the timer scheduled to execute? The run() method can use this
to see whether it was invoked when it was supposed to be return nextTime;
|