From the course: Advanced Java: Threads and Concurrency
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Executing tasks periodically with ScheduledExecutorService - Java Tutorial
From the course: Advanced Java: Threads and Concurrency
Executing tasks periodically with ScheduledExecutorService
- [Instructor] We might not want to execute tasks immediately or as soon as possible all the time. We might want to schedule tasks in our applications for execution when we want. There are mainly two ways in which we may want to schedule tasks, execute a task after a period of time, or execute a task periodically. This is where we need the ScheduledExecutorService. It's another extension of the executor, like the ExecutorService. This interface has three important methods, the overloaded schedule methods that take in a runnable or callable task along with a delay so that the task executes after the given delay in time. ScheduledAtFixedRate method that lets us start a task after an initial delay, and then repeat execution at the given rate or period. If any execution takes longer than the given period, subsequent executions may start late after waiting for the previous run to complete. ScheduleWithFixedDelay method is similar to scheduleAtFixedRate method, but lets us have a…
Contents
-
-
-
-
-
(Locked)
Managing thread execution: Thread pools and executors4m 3s
-
(Locked)
ExecutorService3m 55s
-
(Locked)
Implementing an executor: ExecutorService in action5m 48s
-
(Locked)
Executing tasks periodically with ScheduledExecutorService6m 22s
-
(Locked)
Challenge: Number magic and voting simulator2m 20s
-
(Locked)
Solution: Number magic and voting simulator5m 41s
-
(Locked)
-
-
-
-
-