I would like to know the difference between
CompletableFuture
,Future
and Observable
RxJava
.
What I know is all are asynchronous but
Future.get()
blocks the thread
CompletableFuture
gives the callback methods
RxJava Observable
— similar to CompletableFuture
with other benefits(not sure)
For example: if client needs to make multiple service calls and when we use Futures
(Java) Future.get()
will be executed sequentially…would like to know how its better in RxJava..
And the documentation http://reactivex.io/intro.html says
It is difficult to use Futures to optimally compose conditional asynchronous execution flows (or impossible, since latencies of each request vary at runtime). This can be done, of course, but it quickly becomes complicated (and thus error-prone) or it prematurely blocks on Future.get(), which eliminates the benefit of asynchronous execution.
Really interested to know how RxJava
solves this problem. I found it difficult to understand from the documentation.