The Java Timer class provides a facility for the thread to schedule tasks for future execution in a background thread. This class is thread-safe that means multiple class can share a single Timer object without using the external synchronization.
SN |
Method |
Description |
1 |
cancel() |
It is used to stop the timer and remove the currently scheduled task. |
2 |
Purge() |
It is used to cancel the tasks present in TimerTask Chain. |
3 |
scheduleAtFixedRate(TimerTask task, Date firstTime, long period) |
It is used to schedules the specified task for repeated fixed-rate execution, beginning at the specified time. |
4 |
scheduleAtFixedRate(TimerTask task, long delay, long period) |
It is used to schedules the specified task for repeated fixed-rate execution, beginning after the specified delay. |
5 |
schedule(TimerTask task, Date firstTime, long period) |
It is used to schedules the specified task for repeated fixed-delay execution, beginning at the specified time. |
6 |
schedule(TimerTask task, Date time) |
It is used to schedules the specified task for execution at the specified time. |