Package java.util
Class TimerTask
java.lang.Object
java.util.TimerTask
- All Implemented Interfaces:
Runnable
public abstract class TimerTask extends Object implements Runnable
The
TimerTask class represents a task to run at a specified time. The task
may be run once or repeatedly.- See Also:
Timer,Object.wait(long)
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimerTask()Creates a newTimerTask. -
Method Summary
Modifier and Type Method Description booleancancel()Cancels theTimerTaskand removes it from theTimer's queue.abstract voidrun()The task to run should be specified in the implementation of therun()method.longscheduledExecutionTime()Returns the scheduled execution time.
-
Constructor Details
-
TimerTask
protected TimerTask()Creates a newTimerTask.
-
-
Method Details
-
cancel
public boolean cancel()Cancels theTimerTaskand removes it from theTimer's queue. Generally, it returnsfalseif the call did not prevent aTimerTaskfrom running at least once. Subsequent calls have no effect.- Returns:
trueif the call prevented a scheduled execution from taking place,falseotherwise.
-
scheduledExecutionTime
public long scheduledExecutionTime()Returns the scheduled execution time. If the task execution is in progress it returns the execution time of the ongoing task. Tasks which have not yet run return an undefined value.- Returns:
- the most recent execution time.
-
run
public abstract void run()The task to run should be specified in the implementation of therun()method.
-