Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why CountDownLatch.getCount() returns a long but not an int?

Tags:

People also ask

What is true about Java CountDownLatch?

CountDownLatch in Java is a kind of synchronizer which allows one Thread to wait for one or more Threads before starts processing. This is a very crucial requirement and often needed in server-side core Java applications and having this functionality built-in as CountDownLatch greatly simplifies the development.

Does CountDownLatch block thread?

Simply put, a CountDownLatch has a counter field, which you can decrement as we require. We can then use it to block a calling thread until it's been counted down to zero.


I looked into the code, everything is int -- the parameter passed to CountDownLatch constructor is int, the variable in Sync is int, the return type of Sync.getCount() is int. But CountDownLatch.getCount() returns a long? Wondering why.