Teardown 03 - Mastering LinkedBlockingQueue and LinkedBlockingDeque
Advanced Java Concurrency Teardown — 6 Hours of Expert-Level Training
Teardown 03: Mastering LinkedBlockingQueue and LinkedBlockingDeque
Advanced Java Concurrency Teardown — 6 Hours of Expert-Level Training
If you've ever stared into the abyss of a thread dump at 3 a.m., squinting at a line in LinkedBlockingQueue.java
, wondering why your beautifully architected system is behaving like a hung-over octopus, you're not alone. The blocking collections in java.util.concurrent
are some of the most widely used and least understood parts of the Java platform. That ends now.
In this 6-hour advanced teardown, we go far beyond the javadoc and delve into the guts of two of the JDK's most critical concurrent data structures: LinkedBlockingQueue
and LinkedBlockingDeque
. These are not your run-of-the-mill queues. They’re finely-tuned synchronization tools, backed by linked nodes, subtle lock orchestration, and complex memory behavior that can make or break your system under load.
But this course isn’t just about learning what these classes do. It’s about learning why they behave the way they do, and when that behavior starts to bite. Along the way, we’ll investigate design trade-offs between lock splitting and unified locks, study thread contention patterns under pressure, and explore how the choice of queue can change the performance profile of your thread pool by orders of magnitude.
You’ll see:
- Why
LinkedBlockingQueue
is the default forExecutors.newFixedThreadPool()
, and when that’s a terrible idea. - How
LinkedBlockingDeque
gives you not only FIFO but also LIFO semantics—and why that's useful for poison-pill shutdown and task prioritization. - Subtle JVM memory alignment issues that affect performance and GC pressure.
- Real-world experiments measuring throughput, latency, and concurrency behavior under stress.
And here’s something you don’t often hear in a training pitch: we found and fixed seven real bugs in the OpenJDK while building this course. That’s right—while dissecting the implementation details, we uncovered race conditions, documentation mismatches, deadlocks and performance issues. These were not theoretical curiosities. These were real bugs in the JDK used by millions of developers, and they're now fixed. If nothing else, this speaks to the depth and rigor of what you’re about to experience.
You’ll get access to:
- Hours of meticulously explained teardown videos
- Performance experiments with GC flags and thread tuning
- Exercises with real code, benchmarking techniques, and architectural insights
- Commentary that brings decades of concurrency experience right to your IDE
This isn’t a beginner’s overview. It’s the kind of course you wish existed five years ago, the one that makes you say “Aha!” after your 100th ThreadPoolExecutor
configuration. Whether you’re building scalable backends, tuning latency-sensitive systems, or just hungry to understand how Java concurrency really works, this course is for you.
Ready to join the ranks of Java developers who don’t just use concurrent collections—they master them?
Let’s begin.
Your Instructor
Heinz Kabutz is the author of The Java Specialists’ Newsletter, a publication enjoyed by tens of thousands of Java experts in over 150 countries. He has been a Java Champion since 2005.
Course Curriculum
-
Start3.1.1. LinkedBlockingQueue Code Teardown (0:11)
-
Start3.1.1.1. Quick Overview of Class JavaDocs (1:30)
-
Start3.1.1.2. Explanation of "two lock algorithm" and cascading notifies (7:35)
-
Preview3.1.1.3. Node class for holding items (2:17)
-
Start3.1.1.4. capacity and count fields (0:37)
-
Start3.1.1.5. head and last fields (0:19)
-
Start3.1.1.6. takeLock and putLock, with conditions, signal() methods (2:31)
-
Preview3.1.1.7. enqueue(), dequeue(), preventing zombie objects in old space (11:53)
-
Start3.1.1.8. fullyLock(), fullyUnlock() (0:22)
-
Start3.1.1.9. LinkedBlockingQueue constructors (10:36)
-
Start3.1.1.10. size(), remainingCapacity() (1:29)
-
Start3.1.1.11. put(), take(), offer(), poll(), peek(), element(), remove() (16:29)
-
Start3.1.1.12. unlink() and remove(Object) (13:03)
-
Start3.1.1.13. contains(Object) and ReadWriteLock version (11:04)
-
Start3.1.1.14. toArray() and toString (5:01)
-
Start3.1.1.15. clear() (1:50)
-
Preview3.1.1.16. drainTo() (8:56)
-
Start3.1.1.17. succ(Node) (1:59)
-
Start3.1.1.18. Iteration (2:18)
-
Start3.1.1.18.1. Iterator.next() (2:49)
-
Start3.1.1.18.2. Iterator.forEachRemaining() (22:23)
-
Start3.1.1.18.3. Iterator.remove() (6:03)
-
Start3.1.1.19. Spliterator (2:47)
-
Start3.1.1.19.1. Spliterator.tryAdvance() (2:08)
-
Start3.1.1.19.2. Spliterator.forEachRemaining() and forEach() (2:21)
-
Start3.1.1.19.3. Spliterator.trySplit() (9:53)
-
Start3.1.1.20. removeIf(), retainAll(), removeAll() (5:02)
-
Start3.1.1.21. writeObject(), readObject() (1:37)
-
Start3.1.1.22. Summary of LinkedBlockingQueue Teardown (10:42)