| Modifier | Constructor and Description |
|---|---|
protected |
TimerTask() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel()
Cancels this task and guarantees that this task will never run again.
|
abstract void |
run()
Inherited from
Runnable |
long |
scheduledExecutionTime()
Returns the time at which the most recent execution of this task was scheduled
to occur.
|
public boolean cancel()
If this task is currently running, the current run() will be allowed to complete.
cancel() can be called more than once and it has no effect after the first call.
Returns true iff. at least one run of the task was cancelled. Note that if the
given task wasn’t scheduled, there’s nothing to cancel (by definition) so this method must
return false in that case.
public long scheduledExecutionTime()
Because task execution can occur later than scheduled this method can be used within the
run() method to calculate the difference between the scheduled and actual execution
time.
The return value is undefined for tasks that have never been run.