Package java.util
Class TimerTask
- java.lang.Object
-
- java.util.TimerTask
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimerTask()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancancel()Cancels this task and guarantees that this task will never run again.abstract voidrun()Inherited fromRunnablelongscheduledExecutionTime()Returns the time at which the most recent execution of this task was scheduled to occur.
-
-
-
Method Detail
-
cancel
public boolean cancel()
Cancels this task and guarantees that this task will never run again.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
trueiff. 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 returnfalsein that case.
-
scheduledExecutionTime
public long scheduledExecutionTime()
Returns the time at which the most recent execution of this task was scheduled to occur.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.
-
-