3 ms·
I just started using CompletableFuture last week. The way each method ties your lambdas together without a bunch of type boilerplate is really nice. I still d
by SloopJon 11y ago
I just started using CompletableFuture last week. The way each method ties your lambdas together without a bunch of type boilerplate is really nice. I still don't have a great handle on all of its methods, though; e.g., what's the difference between get() and join()?
- kilink 11y agoCompletableFuture implements Future, so the get method is an implementation of Future.get [1]. Anyway, the major difference is that Future.get throws 2 checked exceptions, InterruptedException and ExecutionException, while CompletableFuture.join does not throw any checked exception. Instead, it wraps any exceptions in CompletionException. [1] https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Future.html#get() https://docs.oracle.com/javase/7/docs/api/java/util/concurre...