CompletableFuture and async composition question 100 of 180 junior
What is the difference between join() and get()?
join()does not block- Correct:
join()throws the uncheckedCompletionException;get()is checked and takes a timeout get()is deprecatedjoin()only works inside a stream
Functionally both block until the result is available. The difference is the exceptions: get() is
Future's method with checked exceptions, and join() is unchecked, which is why it works inside
lambdas and stream pipelines where a checked exception would not compile.
get() is also the one with a timeout overload, and the one that responds to interruption. Use
join() inside a chain where the value is already known to be present, and get(timeout) at the edge
of your system, where you genuinely have to wait.
Quiz yourself on CompletableFuture and async composition Suggest a correction