Which class allows multiple threads to work in parallel but blocks them until all threads are finished?

  • CountDownLatch
  • CyclicBarrier
  • Semaphore
  • ThreadGroup
The CyclicBarrier class allows multiple threads to work in parallel but blocks them until all threads have reached a certain point (barrier) in the code. Once all threads have reached the barrier, they can continue executing. It is commonly used for tasks that can be divided into subtasks that need to be completed before the main task can proceed.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *