O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

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

Attaching a callback to the CompletableFuture

CompletableFuture.get() blocks the object and waits until the Future task is completed and the result is returned. To build an asynchronous system, there should be a callback, automatically called when the Future task has completed. We can attach a callback to CompletableFuture by using the thenApply(), thenAccept(), and thenRun() methods.

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