100 Days of Code #Day8
Continuing our journey on scheduling tasks, We move into scheduling tasks on a recurring manner.
As we see yesterday, java.util.Timer and java.util.TimerTask classes are used to create scheduled task in Java. They can also be used to create a recurring task that executes at every scheduled time.
Timer allows tasks to be scheduled for repeated execution by specifying a fixed rate of execution or a fixed delay between executions.
We can assume the example of alarm clock that sounds a wake up call every morning at the same time. We can schedule the alarm clock to execute every day at same time by adding the delay as 86400 seconds. The timer’s schedule method has a start time and delay (number of seconds after the task has to execute).
#100DaysOfCode #day8