Scala Future vs Java Future

 
Java Future is blocking because it waits if necessary for the computation to complete, and then retrieves its result.
 
Scala Future on the other hand is a real non-blocking computation. You can map the callbacks or chain multiple Futures in monadic fashion.
 
Java 8 has CompletableFuture which implements a Promise (CompletionStage). It can be non-blocking by attaching callbacks. (http://www.deadcoderising.com/java8-writing-asynchronous-code-with-completablefuture/) The code however is more convoluted compared to Scala.
Advertisements