7. What for?
Speed up the application...
Image URL: https://www.thewebmaster.com/media/uploads/files/why-carry-out-a-speed-test-on-website_UczLvGZ.jpg
8. What for?
... in a simpler way than working directly
with threads
Image URL: http://static.codeceo.com/images/2015/01/33095007e134e8630fe35771795f3ac8.jpg
22. Sync vs. Async
The advantage is obvious, isn't it?
Image URL: https://image.slidesharecdn.com/javainhft-141222112349-conversion-gate02/95/java-in-high-frequency-trading-23-638.jpg?cb=1419247883,
http://www.pngall.com/wp-content/uploads/2016/04/Red-Cross-Mark-Transparent.png
23. Sync vs. Async
Make your calls non-blocking!
Image URL: https://s-media-cache-ak0.pinimg.com/600x315/09/60/a3/0960a3cf49ff2c1a23e8b67997b17be6.jpg
26. Java retirement party
How it used to be…
Image URL: https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcTAc9Up87H315tKinSkf8EZ8VfoR46gZfDGR2SjTCG_yOwAJvJ8MA
• Threads
• Future<T>
• ForkJoinPool
• Streams (parallel)
40. API: Simplest asynchronous computation
◦ Pitfall #1:
Specify custom executor to
avoid using default common
pool.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
42. API: Chaining callbacks
◦ Pitfall #2:
Use thenCompose instead of
thenApply to avoid the
nestings.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
44. API: Parallel computations
◦ Pitfall #3:
Keep in mind that the order of
execution is not guaranteed.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
46. API: Dealing with many CompletableFuture instances
◦ Pitfall #4:
We get CompletableFuture<Void>
as the result of execution of all
futures.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
48. API: Dealing with many CompletableFuture instances
◦ Pitfall #5:
We get
CompletableFuture<Object>
as the result of execution of the
fastest future.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
50. API: Exceptions
◦ Pitfall #6:
Exceptions can not be handled
with usual CompletableFuture
methods.
Image URL: http://cdn.ishaya.ir/ponila_bucket/images/00/17/00175721ebb9add9498d86bda11e0ec0/736x/00175721ebb9add9498d86bda11e0ec0.jpg
52. Java 9 concurrency improvements
JEP 266: More Concurrency Updates
8 new methods;
5 new static methods.
Image URL: https://ilaborie.github.io/devfest-toulouse-16-slides/pictures/Java9.png