Search code examples
javajava.util.concurrentcountdownlatch

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


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.


Solution

  • I don't know if you will find a sufficient answer to that question unless someone who designed that API answers, but it does say it is for "debugging and testing".

    public long getCount() {...} // just for debugging and testing