How does the CompletableFuture
introduced in JDK 8 compare with the io.netty.util.concurrent.Future
provided by Netty ?
Netty documentation mentions that
JDK 8 adds CompletableFuture which somewhat overlaps
io.netty.util.concurrent.Future
http://netty.io/wiki/using-as-a-generic-library.html
The questions I'm trying to get answers to are:
- What would their similarities and differences be?
- How would the performance characteristics of the two differ? Which one would be able to scale better?
With respect to the similarities/ differences, I have been able to come up with the following:
Similarities: The fundamental similarity being that both are non-blocking as compared to the Java Future. Both the classes have methods available to add a listener to the future, introspect failure and success of the task and get results from the task.
Differences:
CompletableFuture
seems to have a much richer interface for things like composing multiple async activities etc. Netty's io.netty.util.concurrent.Future
on the other hand allows for multiple listeners to be added to the same Future, and moreover allows for listeners to be removed.