Java.util.concurrent Queues

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

Internal

Overview

Blocking Queue

https://docs.oracle.com/javase/10/docs/api/java/util/concurrent/BlockingQueue.html

java.util.concurrent.BlockingQueue<E> is a java.util.Queue that has operations that wait for the queue to become non-empty when retrieving an element, and wait for space to become available in the queue when storing an element. When configured with a fixed size (example ArrayBlockingQueue), it can be used as a memory sprawl control mechanisms, providing memory-safe separation between threads.

Insertion Operations:

  • put() blocks if the queue is full.
  • add() throws exception if the queue is full.
  • offer() attempts to insert and immediately returns true if the insertion was successful or false if no space is available. offer() has an overloaded version that waits for a time-out.

Removal Operations:

Inspection Operations:

It has the following implementations:

ArrayBlockingQueue

LinkedBlockingQueue