Hello guys, multithreading and concurrency are one of the most important topics for Java interviews and a good knowledge of different concurrent classes and features goes a long way in receiving a good offer.
In the past few posts, I have shared popular Java interview questions like,, How ConcurrentHashMap work in Java? Why String is Immutable, why wait() and notify() is called from synchronized context, and What is the difference between List, List<Object> and today, I am going to share another popular Java Concurrency interview question, difference between CyclicBarrier and CountDownLatch in Java.
One of the most important task in concurrent application is to coordinate between threads like when one thread completes is job the next thread start his job and that’s where CountDownLatch and CyclicBarrier helps.
While I understand that many Java developer don’t get chance to write concurrent code and many of them have not even used wait, notify, CountDownLatch, and CyclicBarrier but you cannot make this excuse on interview. It doesn’t goes well with the interviewer and give them a reason to reject you.
Even if you have not used this classes in real application, having good knowledge of what they are and when to use them is critical to answer this question. So let’s start with that.
Keep reading with a 7-day free trial
Subscribe to Javarevisited Newsletter to keep reading this post and get 7 days of free access to the full post archives.