ReentrantLock in Java

ReentrantLock in Java is part of java.util.concurrent.locks package with in the Java concurrency API added in Java 5 which also has other classes like ConcurrentHashMap, CountDownLatch. ReentrantLock class in Java implements java.util.concurrent.locks.Lock interface and provide many locking operations. ReentrantLock in Java Concurrency The traditional way of acquiring a mutual exclusion…

Continue reading

Phaser in Java

Many synchronization aid were added as the part of java.util.concurrent package in Java 5 like Semaphore, Exchanger. One more synchronization aid added as part of Java concurrency is Phaser which was added in Java 7. Phaser in Java concurrency Phaser in Java is also a synchronization barrier like CountDownLatch and…

Continue reading

Exchanger in Java

Many synchronization aid were added as the part of java.util.concurrent package in Java 5 like CyclicBarrier, Semaphore. One more synchronization aid added as part of Java concurrency is Exchanger. In this post we’ll see what is Exchanger in Java, how does it work and an example of Exchanger. Exchanger in…

Continue reading

CyclicBarrier in Java

The java.util.concurrent package provides many synchronizers utilities that cover the use cases where several thread communicate with each other and some sort of synchronizer is needed to regulate that interaction among the threads. CyclicBarrier in Java is one such synchronization aid that is useful when you want threads to wait…

Continue reading

CopyOnWriteArraySet in Java With Examples

CopyOnWriteArraySet in Java extends the AbstractSet which in turn implements the Set interface and is part of java.util.concurrent package. How CopyOnWriteArraySet differs from other Set implementations in Java Collections framework is that it is thread-safe. CopyOnWriteArraySet internal implementation in Java CopyOnWriteArraySet internally uses CopyOnWriteArrayList for all of its operations and…

Continue reading

ConcurrentSkipListMap in Java

This post talks about the ConcurrentSkipListMap class from the java.util.concurrent package and the interface ConcurrentNavigableMap this class implements. ConcurrentSkipListMap in Java ConcurrentSkipListMap is a thread-safe, scalable Map that stores its elements in sorted manner. By default map is sorted according to the natural ordering of its keys, or by a…

Continue reading

CopyOnWriteArrayList in Java

CopyOnWriteArrayList in Java implements the List interface just like its other well known counterpart ArrayList and is part of java.util.concurrent package. How CopyOnWriteArrayList differs from ArrayList is that it is a thread-safe variant of ArrayList. For more differences between CopyOnWriteArrayList and ArrayList in Java refer this post- Difference Between ArrayList…

Continue reading