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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s