Ace Java 2025: Rock Your 'Thinking in Java' Challenge!

Question: 1 / 510

To reset the count of CountDownLatch, which class can be used instead?

Semaphore

CyclicBarrier

The correct class to use instead of CountDownLatch to reset the count is CyclicBarrier. While ReentrantLock could also be used in certain cases, it is primarily used for providing mutual exclusion between threads. Semaphore and CopyOnWriteArrayList, while they could potentially be used to reset a count, are more commonly used for other purposes such as limiting access to a shared resource and providing thread-safe access to a list, respectively. Thus, B is the most appropriate answer as CyclicBarrier is specifically designed for synchronizing a group of threads and resetting the count as needed.

Get further explanation with Examzify DeepDiveBeta

CopyOnWriteArrayList

ReentrantLock

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy