Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7938553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:50:34+00:00 2026-06-03T22:50:34+00:00

I need some help understanding the advantages of using CountDownLatch over traditional wait-notify. I

  • 0

I need some help understanding the advantages of using CountDownLatch over traditional wait-notify. I think notifyAll() indeed does the same thing, and it seems easier to use (maybe because of familiarity).

Also, what’s the difference between wait() and await() from CountDownLatch ?

Thanks !

EDIT : I guess I need to rephrase my queries :

Await() as per the docs says :

Causes the current thread to wait until the latch has counted down to zero, unless the thread is interrupted.

For me it’s hard to see the difference between wait() and await() – await() is indeed using wait() under covers, and seems there is an implicit notifyAll() when count reached zero.

What I meant to ask was, why shouldn’t I simply use a wait-notifyAll() mechanism (with my own counter variable processing), rather than going for CountDownLatch ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:50:35+00:00Added an answer on June 3, 2026 at 10:50 pm

    They certainly don’t do the same thing: CountDownLatch only signals when the event count has reached 0 and it does so automatically, wait-notify requires you to keep your own count if you want to achieve the same behavior. Implementing the same behavior is often error prone and it’s best that you avoid it (especially if you’re new to concurrency programming). Comparing CountDownLatch and wait-notify is hardly even an apples to oranges comparison, it’s more like comparing an automatic drill and an Allen wrench.

    I don’t know if you’ve used notifyAll() and CountDownLatch, but notifyAll() alone will not give you the same behavior unless you’ve kept count of how many events have occurred. CountDownLatch is probably most suitable for performing a fixed number of tasks and waiting for those tasks to complete before you resume execution of the rest of your program. It’s especially helpful when you have a fixed number of threads (e.g. ThreadPool) executing a fixed number of tasks, but your threads are way fewer than the tasks and you have to reuse them. With a CountDownLatch you can easily wait for all of the tasks to be completed. I don’t know how you’ve been using notifyAll() to achieve the same behavior, but if you provide us with more information we can address which one of the two is a better choice (there are certainly some cases where waitNotify() is more appropriate).

    Regarding the difference between wait() and await(), I’m somewhat disappointed in you! Looking up the documentation is step one of any question:

    http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CountDownLatch.html

    await() is an actual function of CountDownLatch whereas wait() is inherited from Object. I would recommend that you check the documentation for what they do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think I need some help understanding how static objects persist in an ASP.Net
I am using unity 2.0 with MVC3 and need some help understanding the LifeTimeManagers.
I need some help understanding this bit of code pre { white-space: pre; white-space:
I need some help in understanding when and why to use Remote Service instead
I need some help in understanding what is happening here .I am getting a
I have been trying out Cassandra and need some help in understanding a few
Need some help understanding why my concat() is failing and how to fix it.
I need some help understanding some of the points from Paul Graham’s What Made
I need some help understanding what's happening here. This code is from a models/log.py
I need some help understanding the correct way to mix variables with strings like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.