The biggest advantage of using it ScheduledExecutorServiceis that you do not need to write code and that it is well tested. It also supports canceling tasks out of the box, and you can schedule more than one task.
Another advantage is that other developers know what ScheduledExecutorServicethey are doing , they can read javadoc, and they can ask questions about it in puppet forums and get help, while it’s harder to get help for custom code.The javadoc for ScheduledExecutorService also has a good example of how to create tasks that run every 10 seconds for an hour, and then cancel.
source
share