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

143 comments:

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

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

    ReplyDelete
  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

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

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

    ReplyDelete
  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

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

    ReplyDelete
  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.

    ReplyDelete
  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

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

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

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

    ReplyDelete
  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

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

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

    data science course

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

    ReplyDelete
  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

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

    Bird Accessories

    ReplyDelete

  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

    ReplyDelete
  26. Thank you so much for this incredible guide. This has given me so much information
    AI Training in Hyderabad

    ReplyDelete
  27. I prefer to study this kind of material. Nicely written information in this post, the quality of content is fine and the conclusion is lovely. Things are very open and intensely clear explanation of issues.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.
    Data Science Training In Chennai

    Data Science Online Training In Chennai

    Data Science Training In Bangalore

    Data Science Training In Hyderabad

    Data Science Training In Coimbatore

    Data Science Training

    Data Science Online Training

    ReplyDelete
  28. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    Simple Linear Regression

    Correlation vs Covariance

    ReplyDelete
  29. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.
    Correlation vs Covariance
    Simple linear regression
    data science interview questions

    ReplyDelete
  30. Data Science course in chennai
    The information given in this blog is very nice and i like it if you share more this kind of blog and i also have written this kind of blog you can also read for more knowledge.

    ReplyDelete
  31. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it up.

    Data Science Training in Hyderabad

    ReplyDelete
  32. Thank you so much for this incredible guide. This has given me so much information
    AI Training in Hyderabad

    ReplyDelete
  33. Thanks for posting useful information.You have provided an nice article,

    DevOps Training in Hyderabad

    ReplyDelete
  34. php interview questions and answers
    Important PHP and MySQL Interview Questions and Answers for freshers and experienced to get your dream job in PHP! Basic & Advanced PHP Interview Questions for Freshers & Experienced.

    ReplyDelete
  35. nodejs interview questions
    Important Node JS Interview Questions and Answers for freshers and experienced to get your dream job & Advanced Node.JS Interview Questions for Freshers & Experienced.

    ReplyDelete
  36. This Was An Amazing ! I Haven't Seen This Type of Blog Ever ! Thankyou For Sharing, data science course in hyderabad with placements

    ReplyDelete
  37. I am looking for and I love to post a comment that "The content of your post is awesome" Great work!

    Simple Linear Regression

    Correlation vs covariance

    KNN Algorithm

    Logistic Regression explained

    ReplyDelete
  38. Nice content very helpful, It has a very important point which should be noted down. All points mentioned and very well written. Keep Posting & writing such content

    AWS Online Training
    Online AWS Certification Training

    ReplyDelete
  39. This blog is really nice and informative blog, The explanation given is really comprehensive and informative.
    I really enjoy simply reading all of your post. Simply wanted to inform you that you have people like me who appreciate your work.
    Angular js Training in Chenai

    Angular js Training in Velachery

    Angular js Training in Tambaram

    Angular js Training in Porur

    Angular js Training in Omr
    Angular js Training in Annanagar

    ReplyDelete
  40. A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one
    Digital Marketing Courses in Hyderabad With Placements

    ReplyDelete
  41. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    tally training in chennai

    hadoop training in chennai

    sap training in chennai

    oracle training in chennai

    angular js training in chennai

    ReplyDelete
  42. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
    salesforce training in chennai

    software testing training course in chennai

    robotic process automation rpa training in chennai

    blockchain training in chennai

    devops training in chennai

    ReplyDelete
  43. Attend The Data Analyst Course From ExcelR. Practical Data Analyst Course Sessions With Assured Placement Support From Experienced Faculty. ExcelR Offers The Data Analyst Course.
    Data Analyst Course

    ReplyDelete
  44. Thanks for your awesome post!!! I am reading your blog regularly. I like so much and i want addition info from your post.
    IOS Training Institute
    IOS Coaching
    IOS Classes
    Java training
    Java online trainingBigdata Training in Chennai
    Bigdata course in Chennai

    ReplyDelete
  45. Very informative post ! There is a lot of information here that can help any business get started with a successful social networking campaign !
    business analytics course


    ReplyDelete
  46. Artificial intelligence and computer vision share other topics such as pattern recognition and learning techniques. Consequently, computer vision is sometimes seen as a part of the artificial intelligence field or the computer science field in general. data science course in india

    ReplyDelete
  47. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Data Science training

    ReplyDelete
  48. Highly appreciable regarding the uniqueness of the content. This perhaps makes the readers feels excited to get stick to the subject. Certainly, the learners would thank the blogger to come up with the innovative content which keeps the readers to be up to date to stand by the competition. Once again nice blog keep it up and keep sharing the content as always.

    Data Science training in Bhilai

    ReplyDelete
  49. This post is very simple to read and appreciate without leaving any details out. Great work!
    data scientists training

    ReplyDelete
  50. Thanks for posting the best information and the blog is very helpful.data science interview questions and answers

    ReplyDelete
  51. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    data science institute in bangalore

    ReplyDelete
  52. Very excellent post!!! Thank you so much for your great content. Keep posting.....

    Python Training In Bangalore
    Python Training Institute In Bangalore

    ReplyDelete
  53. It is imperative that we read blog post very carefully. I am already done it and find that this post is really amazing.
    data scientist training and placement in hyderabad

    ReplyDelete
  54. Amazing Blog ,Very useful to Visit Your page , Keep Updating More .
    JAVA Training in Chennai
    Java Training in Bangalore

    ReplyDelete
  55. Thanks for sharing the valuable information. This blog contains various good concept and ideas.
    Python Training in Hyderabad
    Python Course in Hyderabad

    ReplyDelete
  56. Hi, great... Tutorial is just awesome. It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging.
    AWS Training in Hyderabad
    AWS Course in Hyderabad

    ReplyDelete
  57. Quite an insightful post. This has cleared so many of my doubts in this subject & has thrown light on many aspects that I didn’t know before. Thanks a ton!
    Data Science Training in Hyderabad
    Data Science Course in Hyderabad

    ReplyDelete
  58. I got to favourite this web site it seems very useful very beneficial
    DevOps Training in Hyderabad
    DevOps Course in Hyderabad

    ReplyDelete
  59. I was basically inspecting through the web filtering for certain data and ran over your blog. I am flabbergasted by the data that you have on this blog. It shows how well you welcome this subject. Bookmarked this page, will return for extra. data science course in jaipur

    ReplyDelete
  60. Thanks for bringing such innovative content which truly attracts the readers towards you. Certainly, your blog competes with your co-bloggers to come up with the newly updated info. Finally, kudos to you.

    Data Science Course in Varanasi

    ReplyDelete
  61. Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

    Data Science Course in Bhilai

    ReplyDelete
  62. Impressive blog to be honest definitely this post will inspire many more upcoming aspirants. Eventually, this makes the participants to experience and innovate themselves through knowledge wise by visiting this kind of a blog. Once again excellent job keep inspiring with your cool stuff.

    Data Science Training in Bhilai

    ReplyDelete
  63. Extremely overall quite fascinating post. I was searching for this sort of data and delighted in perusing this one. Continue posting. A debt of gratitude is in order for sharing. data scientist course in delhi

    ReplyDelete
  64. Thanks for posting the best information and the blog is very good.data science institutes in hyderabad

    ReplyDelete
  65. Really Superb! Thanks for sharing this useful information.
    Farina Hair Care

    ReplyDelete
  66. I feel happy to say this I have learnt new things from your blog and it’s really useful for me, keep sharing valuable information regularly.
    Ramakrishnan Interview

    ReplyDelete
  67. Awesome blog. Thank you for sharing such a useful information.
    Dharsha Gupta Interview

    ReplyDelete
  68. Your blog is very interesting to read and easy to understand. Keep on blogging.
    Actress Monika Interview

    ReplyDelete
  69. Thanks for sharing the nice article, keep updating news article.
    Chill Bro Bala

    ReplyDelete
  70. I recently read your post and I got a lot of information. Keep on sharing more blogs like this.
    Milla Exclusive Interview

    ReplyDelete
  71. Thank you for allowing me to read it, welcome to the next in a recent article.
    Dharsha Gupta

    ReplyDelete
  72. Your website is really cool and this is a great inspiring article.
    Sam Anderson

    ReplyDelete
  73. Your blog is very informative. Thanks for sharing such a useful information with us.
    Rachitha Mahalakshmi Haircare

    ReplyDelete
  74. Very nice information. Thank you for sharing it.
    Chill Bro

    ReplyDelete
  75. Your blog is very easy to understand many concepts and I got a lot of information.Thanks for sharing.
    Yamuna Chinnadurai Interview

    ReplyDelete
  76. Best article.Thanks for sharing this.
    Kavin

    ReplyDelete
  77. Great post.It's very useful for me to understand the information.Keep on blogging.
    Dharsha Gupta Emotional

    ReplyDelete
  78. Thanks for your informative article. Keep on sharing.
    Kuhasini Interview

    ReplyDelete
  79. I got to favourite this web site it seems very useful very beneficial
    Theni Eswar

    ReplyDelete
  80. Great blog.thanks for sharing such a useful information
    BDD with Cucumber Online Training

    ReplyDelete
  81. Very nice piece of information, please keep updating and share your valuable information with us.
    Mime Gopi

    ReplyDelete
  82. Really awesome Blog.Thanks for sharing this.
    Sakthi Chidambaram

    ReplyDelete
  83. Excellent blog! So many ideas in a single site. Thanks for the informative article. Keep updating more article.
    Jeeva Subramaniyam

    ReplyDelete
  84. Best blog i had ever read.Thanks for sharing this.
    Bigg Boss 5 Tamil Live

    ReplyDelete
  85. This blog is a great source of information which is very useful for me. Keep sharing more article like this.
    Milla Babygal

    ReplyDelete
  86. Excellent blog. Thanks for sharing such a useful information. Keep on blogging.
    Tn Local Body Election 2021

    ReplyDelete
  87. This blog is really nice and informative blog, The explanation given is really comprehensive and informative.
    Dhilip Subbarayan

    ReplyDelete
  88. Really very useful article for us. Thanks for sharing such an informative blog.
    Fish Curry and Fry

    ReplyDelete
  89. Very informative article. Thanks for posting this useful content.
    Yamuna Skincare

    ReplyDelete
  90. Nice article. The information you give is very interesting.
    Actress Anagha

    ReplyDelete
  91. Great blog. Thanks for sharing such a useful information.
    Java training chennai

    ReplyDelete