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

There's more...

In the example of this recipe, we used the complete(), get(), join(), supplyAsync(), thenApplyAsync(), thenAcceptAsync(), and allOf() methods of the CompletableFuture class. However, this class has a lot of useful methods that help increase the power and flexibility of this class. These are the most interesting ones:

  • Methods to complete a CompletableFuture object: In addition to the complete() method, the CompletableFuture class provides the following three methods:
    • cancel(): This completes CompletableFuture with a CancellationException exception.
    • completeAsync(): This completes CompletableFuture with the result of the Supplier object passed as a parameter. The Supplier object is executed in a different thread by the default ...

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