From the course: Advanced Java: Threads and Concurrency
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
CompletableFuture - Java Tutorial
From the course: Advanced Java: Threads and Concurrency
CompletableFuture
- [Instructor] Future is all good for asynchronous programming, but let's say, a time-consuming database access task cannot be completed because the remote database service don't for some reason. In this situation, your application might want to complete the task manually by returning, let's say, the last cache data for the request. This isn't possible with future. This is just one of the limitations of future. I'm talking about some more in this video. In Java 8, the CompletableFuture Class was introduced as an extension of Future. Along with the future interface, it also implements the completion stage interface. A completion stage represents a stage of an asynchronous computation. As a result, the class has a large number of convenience methods, and is almost like a framework for asynchronous programming. To start with, here are some of those methods. Complete. To manually complete a future, call us waiting for the future, we'll get the value specified by result value parameter…