How it works...
In this recipe, you implemented the MyScheduledTask class to implement a custom task that can be executed on a ScheduledThreadPoolExecutor executor. This class extends the FutureTask class and implements the RunnableScheduledFuture interface. It implements the RunnableScheduledFuture interface because all the tasks executed in a scheduled executor must implement this interface and extend the FutureTask class. This is because this class provides valid implementations of the methods declared in the RunnableScheduledFuture interface. All the interfaces and classes mentioned earlier are parameterized classes and they possess the type of data that will be returned by the tasks.
To use a MyScheduledTask task in a scheduled executor, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access