Timer class methods in Java

java.util.Timer

A facility for threads to schedule tasks for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals.


Some methods of Timer class


cancel(): This method terminates this timer, discarding any currently scheduled tasks.


purge(): This method removes all canceled tasks from this timer's task queue.


schedule(TimerTask, Date): This method schedules the specified task for execution at the specified time.


schedule(TimerTask, long): This method schedules the specified task for execution after the specified delay.


schedule(TimerTask, Date, long): This method schedules the specified task for repeated fixed-delay execution, beginning at the specified time.


schedule(TimerTask, long, long): This method schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.


scheduleAtFixedRate(TimerTask, Date, long): This method schedules the specified task for repeated fixed-rate execution, beginning at the specified time.


scheduleAtFixedRate(TimerTask, long, long): This method schedules the specified task for repeated fixed-rate execution, beginning after the specified delay.


No comments:

Post a Comment