public class Timer extends Object
|Modifier and Type||Class and Description|
|Constructor and Description|
Creates a new
|Modifier and Type||Method and Description|
Terminates this timer, discarding any currently scheduled tasks.
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
public Timer(boolean isDeamon)
truethe background thread wil run as deamon.
public void schedule(Timer.Task task, long delay, long period)
task- task to be scheduled.
delay- delay in milliseconds before task is to be executed.
period- time in milliseconds between successive task executions.
IllegalArgumentException- if delay is negative, or delay + System.currentTimeMillis() is negative.
IllegalStateException- if task was already scheduled or cancelled, timer was cancelled, or timer thread terminated.
Timer.schedule(java.util.TimerTask, long, long)
public void cancel()
Note that calling this method from within the run method of a timer task that was invoked by this timer absolutely guarantees that the ongoing task execution is the last task execution that will ever be performed by this timer.
This method may be called repeatedly; the second and subsequent calls have no effect.
Copyright © 2004-2019 The Apache Software Foundation. All Rights Reserved.