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

PriorityBlockingQueue in Java

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

Condition Interface in Java

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

Java ConcurrentHashMap With Examples

ConcurrentHashMap in Java is a thread safe Map implementation which provides another alternative to be used in a multithreaded environment apart from HashTable or explicitly synchronizing HashMap. ConcurrentHashMap is part of the java.util.concurrent package. Table of contents How is ConcurrentHashMap a better option Internal implementation of ConcurrentHashMap in Java Java…

Continue reading