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