Limitations of Future:
- If you are calling a remote api and after sometimes the remote API service is down, then you want to complete the Future manually by the last cached data. But it cannot be done by Future.
- Future has methods like get() and isDone(). Future does not notify you about its completion. It provides a get() method which blocks until the result is available.
- Multiple Futures can not be chained together.
- Multiple Futures can not be combined together.
- No exception handling is available in Future.
- CompletableFuture implements Future and CompletionStage interfaces
- It provides a huge set of convenience methods for creating, chaining and combining multiple Futures.
- It also provides a very comprehensive exception handling support.
Resource Link: https://www.callicoder.com/java-8-completablefuture-tutorial/
No comments:
Post a Comment