Skip to content

Commit 93d64b3

Browse files
committed
feat: add TaskSubmissionSystem using ConcurrentLinkedQueue for non-blocking task processing
Implemented TaskSubmissionSystem.java to demonstrate a lock-free producer-consumer model using ConcurrentLinkedQueue. Showcases non-blocking insertion and retrieval operations (add, poll) suitable for high-throughput concurrent environments where threads operate without synchronization locks. Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 072b12b commit 93d64b3

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Section 25 Collections Frameworks/Queue Interface/Concurrent Linked Queue/src/TaskSubmissionSystem.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import java.util.concurrent.ConcurrentLinkedQueue;
22

3-
/**
4-
* MAP --> THREAD SAFE --> ConcurrentHashMap
5-
*
6-
* @see ConcurrentMap.ConcurrentHashMapDemo.ConcurrentHashMapDemo
7-
*/
8-
93
public class TaskSubmissionSystem {
104
private static ConcurrentLinkedQueue<String> taskQueue = new ConcurrentLinkedQueue<>();
115

126
public static void main(String[] args) {
13-
147
Thread producer = new Thread(() -> {
158
while (true) {
169
try {
@@ -31,8 +24,13 @@ public static void main(String[] args) {
3124
}
3225
}
3326
});
34-
3527
producer.start();
3628
consumer.start();
3729
}
38-
}
30+
}
31+
32+
/*
33+
We use the Same Technique used here.
34+
35+
MAP --> THREAD SAFE --> ConcurrentHashMap
36+
*/

0 commit comments

Comments
 (0)