JDK Timer is a simple scheduler for a specified task for repeated fixed-delay execution. To use this, you have to extends the TimerTask abstract class, override the run() method with your scheduler function.
RunMeTask.java
Now, you can schedule it by calling the schedule() method of Timer.
App.java
In this example, the timer will print the “Run Me ~” message every 60 seconds, with a 1 second delay for the first time of execution.
No comments:
Post a Comment