Java Concurrency (java.util.concurrent)
Table of Contents
The java.util.concurrent package (JSR-166) is a masterpiece of design by Doug Lea and others. It provides a standardized framework for asynchronous task execution, thread-safe collections, and advanced synchronization primitives.
This series explores the source code of the package to understand the engineering trade-offs and implementation details behind some of the most critical components of the JVM.
Table of Contents #
Executors: The core of Java’s task execution framework.
Queues: Thread-safe data structures for producer-consumer patterns.
- BlockingQueue Interface Overview.
- ArrayBlockingQueue, LinkedBlockingQueue, SynchronousQueue.
- LinkedTransferQueue and ConcurrentLinkedQueue.
- Specialized Blocking Queues:
DelayQueueandPriorityBlockingQueue.
Synchronizers: Advanced coordination primitives.
- AbstractQueuedSynchronizer (AQS): The cornerstone of the framework.
- Semaphore, CountDownLatch, CyclicBarrier.
- Phaser and Exchanger.
Concurrent Collections: Scalable collections for multi-threaded environments.
- ConcurrentMap and ConcurrentHashMap.
- ConcurrentSkipListMap and CopyOnWriteArrayList.
- Concurrent Sets:
ConcurrentSkipListSetandCopyOnWriteArraySet.
Atomics and Locks: The foundation of wait-free and lock-free programming.
- Atomic Variables and
Advanced Atomics (
AtomicReference,FieldUpdaters). - LongAdder and LockSupport.
- ReentrantLock, ReentrantReadWriteLock, and StampedLock.
- Atomic Variables and
Advanced Atomics (
Modern & Advanced Concurrency: The future of Java threading.
- ForkJoinPool and CompletableFuture.
- Structured Concurrency (Loom).
- Reactive Streams (Flow API).
- Random and Helpers (
ThreadLocalRandom,CompletionService).
This textbook is complete, covering all 60+ major classes in the java.util.concurrent package.