Advanced Multi Threading in Java [ Latch ] - Part 1

CountDown latch is one of the kinds of synchronizer which wait for another thread before performing the tasks or This is used to synchronize one or more tasks by enabling them to wait for the tasks completed by other tasks.  It was introduced in Java 5 along with other CyclicBarrier, Semaphore, CuncurrentHashMap and BlockingQueue. Its somehow like the wait and notify but in the more simpler form and will much less code.

It basically works in the latch principle. Or let us suppose we have a seller who is going to sell 10 (No. of operations) apples. The number of customers may be anything but what the seller is concerned about is the number of apples because when it reaches to 0 he can go home. The seller(Main Thread) will wait for the customers (awaits()). Let's say there are 10 customers(Threads) now who are in the line to buy Apple. When one customer buys that Apple then the number of apple decrease by 1 (countdown()) and another customer will get a chance to buy that apple so on the number of apples goes on decreases and finally become 0. After no apples left in the bucket, the seller can stop selling and go home happily. 

Note:: In CountDown Latch the countdown cannot be reset. 

Image result for CountDownLatch

Let's have a look at Java code::

#HappyCoding #CodingWorkspace


  1. Very impressive article. Hope to see more from you.

  2. Nice post.Thanks for sharing this post .I really appreciate the kind of topics you post here.
    manufacturing erp software in chennai

  3. Thank you for this post. Thats all I are able to say. You most absolutely have built this blog website into something speciel. You clearly know what you are working on, youve insured so many corners.thanks

    java training in chennai | java training in bangalore

    java online training | java training in pune

    selenium training in chennai

    selenium training in bangalore

  4. This comment has been removed by the author.

  5. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.

    angularjs Training in online

    angularjs Training in bangalore

    angularjs Training in bangalore

    angularjs Training in btm

  6. Thank you for this post. Thats all I are able to say. You most absolutely have built this blog website into something speciel. You clearly know what you are working on, youve insured so many corners.thanks

    Java Training in Chennai

  7. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    python online training
    python training in OMR
    python training course in chennai

  8. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Devops Training in pune

  9. You are doing a great job. I would like to appreciate your work for good accuracy
    PHP Training in Chennai | PHP Course in Chennai

  10. In the beginning, I would like to thank you much about this great post. Its very useful and helpful for anyone looking for tips. I like your writing style and I hope you will keep doing this good working.
    CCNA Course in Chennai
    CCNA Training in Chennai
    DevOps Training in Chennai
    Digital Marketing Training in Chennai
    SEO Training in Chennai
    CCNA Training in Anna Nagar
    CCNA Course in T Nagar

  11. thanks for your information i got information keep sharing web design company in velachery

  12. Really very happy to say, your post is very interesting to read. I never stop myself to say something about it.You’re doing a great job. Keep it up...

    Upgrade your career Learn SAP ABAP Training from industry experts get Complete hands-on Training, Interview preparation, and Job Assistance at Softgen Infotech Located in BTM Layout.

  13. Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
    artificial intelligence course in hyderabad

  14. Nice blog,I understood the topic very clearly,And want to study more like this.
    Data Scientist Course

  15. The concept has been explained very well. Gained clear knowledge about the prominence of AWS
    AWS Training in Hyderabad

  16. Thank you for sharing such a wonderful articles. Keep sharing
    AWS Training In Hyderabad

  17. Expected to form you an almost no word to thank you once more with respect to the decent recommendations you've contributed here.
    Machine Learning Training In Hyderabad

    Machine Learning Course In Hyderabad

  18. Nice Post ! really enjoyed reading this article. Thanks for sharing such detailed information.
    AI Training in Hyderabad

  19. cool stuff you have and you keep overhaul every one of us

    data science course

  20. Greetings. I know this is somewhat off-topic, but I was wondering if you knew where I could get a capt ha plugin for my comment form? I’m using the same blog platform like yours, and I’m having difficulty finding one? Thanks a lot. Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery

  21. I do agree your blog for quiz programming concepts, which is very helpful to grow up your knowledge. keep sharing more
    AWS training in chennai | AWS training in annanagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

  22. This is a great inspiring article. I am pretty much pleased with your good work. You put really very helpful information.
    Artificial Intelligence Training in Hyderabad

  23. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    Simple Linear Regression

    Correlation vs Covariance

  24. Nice blog,I understood the topic very clearly,And want to study more like this.

    Bird Accessories


  25. Great Article
    Cloud Computing Projects

    Networking Projects

    Final Year Projects for CSE

    JavaScript Training in Chennai

    JavaScript Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training