How it works...

The done() method is called by the FutureTask class when the task that is being controlled finishes its execution. In this example, you implemented a Callable object, the ExecutableTask class, and then a subclass of the FutureTask class that controls the execution of the ExecutableTask objects.

The done() method is called internally by the FutureTask class after establishing the return value and changing the status of the task to isDone. You can't change the result value of the task or change its status, but you can close resources used by the task, write log messages, or send notifications. The FutureTask class might be used to ensure that a specific task is run only once, as calling its run() method will execute its wrapped ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.