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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response