Since Java 5, the core Java APIs have been enhanced with more features for handling coordination between threads in concurrent programming. In this post, we discuss a class in the java.util.concurrent package that aids in this purpose: the CountDownLatch.
Introduction
The CountDownLatch class enables us to coordinate threads by introducing awareness of the number of threads that are carrying out related tasks and keeping track of the number of threads that have completed their task.