Skip to content

Commit a57f07a

Browse files
committed
feat: Blocking Queue
Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 2fce887 commit a57f07a

File tree

2 files changed

+27
-17
lines changed

2 files changed

+27
-17
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
BlockingQueue<E> is a thread-safe queue that supports operations that wait for space availability when
2+
inserting elements and for non-empty conditions when retrieving them.
3+
4+
It provides four types of methods for handling operations: throwing exceptions, returning special values,
5+
blocking indefinitely, and blocking for a limited time.
6+
7+
BlockingQueue is primarily used for producer-consumer scenarios, does not accept null elements,
8+
and may be capacity-bounded. It does not support intrinsic shutdown operations but can use special end-of-stream
9+
objects for termination. Memory consistency is ensured through the happens-before principle.
10+
11+
Medium Summary:
12+
13+
BlockingQueue<E> is an interface in java.util.concurrent that extends Queue<E> with additional methods for
14+
handling concurrent producer-consumer scenarios.
15+
16+
It allows elements to be added or retrieved while managing blocking conditions when the queue is full or empty.
17+
18+
Operations can either throw exceptions, return special values, block indefinitely, or block for a specified time.
19+
20+
BlockingQueue does not accept null elements, ensuring robustness in concurrent environments.
21+
22+
It may have a bounded capacity and provides thread safety using internal locks or concurrency
23+
controls. While it supports bulk operations from Collection, they may not be atomic.
24+
25+
Unlike traditional queues, it lacks a built-in shutdown mechanism, but producers can insert special termination objects.
26+
27+
The interface follows memory consistency rules, ensuring proper synchronization between threads.

Section 25 Collections Frameworks/Queue Interface/Blocking Queue/src/SummaryBlockingQueue.txt

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)