---
title: "What is a CountDownLatch?"  
description: "This is a more advanced type of synchronization that can be done with concurrent package.Consider the example where a organization needs to recruite 3"  
author: "Anupam Mishra"  
published: 2015-11-04  
updated: 2018-03-13  
canonical: https://www.mindstick.com/blog/10979/what-is-a-countdownlatch  
category: "java"  
tags: ["java", "threading"]  
reading_time: 3 minutes  

---

# What is a CountDownLatch?

##### This is a more advanced type of synchronization

that can be done with concurrent package.Consider the example where a [organization](https://answers.mindstick.com/qa/100623/what-is-the-role-of-the-world-health-organization-in-global-health) needs to recruite 3 javadevelopers . for this HRManager has asked 3 [tech](https://www.mindstick.com/services/technologies) [leads](https://www.mindstick.com/articles/12410/how-can-online-leads-lift-your-roi) to take interview. The HR manger wants to distribute the offer letter. only after all the 3 java developershave been recruited. In [Threading](https://www.mindstick.com/blog/187/threading-in-c-sharp) terminology the HR Manger should wait till 3 [java developers](https://www.mindstick.com/articles/12875/blunders-you-must-avoid-while-hiring-java-developers-to-get-the-best-fulfilling-your-needs) have been recruited.

> ```
> import java.util.concurrent.CountDownLatch;public class HRManager  {       public static void main(String args[])           {                CountDownLatch countDownLatch=new CountDownLatch(3);                TechLead techLead1=new TechLead(countDownLatch,"first");                TechLead techLead2=new TechLead(countDownLatch,"second");                 TechLead techLead3=new TechLead(countDownLatch,"third");                   techLead1.start();                   techLead2.start();                    techLead3.start();              try                 {                     System.out.println("HR Manger waiting for recruitment to complete----");                     countDownLatch.await();                                    System.out.println("Distribute Offer Letter");              }catch(InterruptedException e)                    {                        e.printStackTrace();                     }              }}class TechLead extends Thread   {       CountDownLatch countDownLatch;            public TechLead(CountDownLatch countDownLatch,String name)               {                   super(name);                    this.countDownLatch=countDownLatch;                                   }           public void run()              {                  try{                         Thread.sleep(2000);                       }catch(InterruptedException e)                           {                              e.printStackTrace();                           }                System.out.println(Thread.currentThread().getName()+": recruited");            countDownLatch.countDown();         }}
> ```

---

Original Source: https://www.mindstick.com/blog/10979/what-is-a-countdownlatch

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
