Concurrency in non-trivial systems is difficult. java.util.concurrent. CountDownLatch
is one of my favourite concurrent core Java classes, because it simplifies the synchronization of threads. This class is useful when you want to wait until some task in another thread completes, before continuing in the current thread.