countdownlatch

Use of CountDownLatch in java concurrency

Introduction In java concurrency, it is very important to control access to shared variables, sometimes we also want to control the order of execution of concurrent threads, for example: wait for all threads to finish executing before executing another thread, or wait for all threads to be ready before starting the execution of all threads, This time we can use CountDownLatch. CountDownLatch contains a counter that is placed in the QueuedSynchronizer.