Most blogs explaining Java’s CompletableFuture rely on trivial examples (looking at you javatpoint). Those examples can already be provided and well-explained by ChatGPT et al. Furthermore, while they provide only a shallow understanding for beginner developers, they fail to offer anything challenging or insightful for seasoned developers. A more interesting and insightful example of the ... Read more The post CompletableFuture Example: Crawler appeared first on Concurrency Deep Dives.| Concurrency Deep Dives
On the standard library, Java has many “futures”: All these live within package java.util.concurrent. In this post, we focus on CompletableFuture, and its relation to Future. If you want to know more about CompletableFuture, namely what it is, and how to use it, there is a practical guide at A Guide to CompletableFuture. For contextualisation, ... Read more The post Java’s CompletableFuture vs. Future appeared first on Concurrency Deep Dives.| Concurrency Deep Dives
As explained in greater detail in A Guide to CompletableFuture there are 4 ways to create a CompletableFuture: Here we analyse runAsync and supplyAsync in detail, giving some practical examples. These two methods are the most used by programmers on day-to-day. These methods are static on class CompletableFuture, so you don’t need to have a ... Read more The post CompletableFuture runAsync & supplyAsync appeared first on Concurrency Deep Dives.| Concurrency Deep Dives
Overview This is an in-depth practical guide on how to use Java’s CompletableFuture. It is comprehensive and will serve you as a reference for when you have to work with them. It provides unique insights into how they operate, which you won’t easily find in other blogs and books. This will help you develop a ... Read more The post A Guide to CompletableFuture appeared first on Concurrency Deep Dives.| Concurrency Deep Dives
Schedulers, in Java and other languages, allow you to: In Java, there are two classes on the standard library to achieve this: java.util.Timer and java.util.concurrent.ScheduledExecutorService. Some third-party libraries implement the functionality as well. Its common that “concurrency libraries” have their own implementations that integrate better with their framework. For example the akka library/toolkit exposes their ... Read more| Concurrency Deep Dives
As software engineers, we can’t reinvent the wheel. Using external libraries is inescapable. In fact, not using them would be unprofessional. What team would develop a http service from scratch using “bare” Sockets, rather than using well tested, battle harden frameworks like Vert.x or Akka Http which were designed by experts? Sadly, this does lead ... Read more| Concurrency Deep Dives
How to transform a plain Java Future into a CompletableFuture the right way using a scheduler. Don't block the original future.| Concurrency Deep Dives