Friday, July 24, 2015

Playing with Java 8’s Completable Futures

0 comments
Of the many additions to Java 8 such as the Stream API and lambdas, I noticed one of the lesser talked about ones was CompletableFutures. So I decided to have a play around with them on the last Java component I wrote. My use case in a nutshell was piping large volumes of data from a distributed file system, compressing it and uploading to individual destinations on Amazon S3. playing-with-java8

For anyone who has worked with Guava’s ListenableFutures, which allow you to add a completion listener to a regular Java future, CompletableFutures are along the same line as these with a bit more functionality — such as easily composing multiple stages of future work for a single computation. To create a basic CompletableFuture is as simple as creating an existing Future, the following example shows the creation and retrieval of a computation:

read more here

Leave a Reply

 
All Tech News IN © 2011 DheTemplate.com & Main Blogger .