Java CopyOnWriteArraySet 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. Table of contents CopyOnWriteArraySet internal implementation in Java Features of the CopyOnWriteArraySet Java CopyOnWriteArraySet constructors…

Continue reading

Java ConcurrentSkipListMap With Examples

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

LinkedBlockingQueue in Java With Examples

LinkedBlockingQueue in Java is an implementation of BlockingQueue interface and is part of java.util.concurrent package. LinkedBlockingQueue has the features of both ArrayBlockingQueue and DelayQueue. ArrayBlockingQueue is a bounded blocking queue where as DelayQueue is an unbounded blocking queue. LinkedBlockingQueue sits in the middle as it is an optionally-bounded blocking queue…

Continue reading

ConcurrentLinkedQueue in Java With Examples

ConcurrentLinkedQueue in Java is an unbounded queue which is thread-safe. It stores its elements as linked nodes where each node stores a reference to the next node. ConcurrentLinkedQueue class implements Queue interface and is part of java.util.concurrent package. How ConcurrentLinkedQueue differs from the BlockingQueue implementations like ArrayBlockingQueue, PriorityBlockingQueue is that…

Continue reading

PriorityBlockingQueue in Java With Examples

PriorityBlockingQueue in Java is an implementation of BlockingQueue interface and is part of java.util.concurrent package. PriorityBlockingQueue is an unbounded queue PriorityBlockingQueue is logically unbounded, that’s how it differs from ArrayBlockingQueue which is a bounded queue and LinkedBlockingQueue which is optionally-bounded. PriorityBlockingQueue though unbounded is created with an initial capacity which…

Continue reading

Java Condition Interface

Condition interface which resides in java.util.concurrent.locks has methods for inter thread communication similar to Object class monitor methods (wait, notify and notifyAll). Condition provides methods like await(), signal(), signalAll(). Where a Lock replaces the use of synchronized methods and statements, a Condition replaces the use of the Object monitor methods.…

Continue reading