O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required