Java
229 notes
Some notes are currently available only in Chinese. English translations are shown when available.
- 6.25 Implementing a Simple AQS by Handhistorical
Writing a simplified AQS illustrates how an exclusive lock records its owner and how other threads wait and resume.
- 6.27 BlockingQueuehistorical
BlockingQueue provides a thread-safe blocking-queue interface. These notes examine enqueue and dequeue operations, waiting, timeouts, and failure behaviors.
- 6.28 Executorshistorical
Executors provides factory methods for different thread pools. These notes compare cached, fixed-size, single-threaded, and scheduled pools through examples.
- 6.29 ConcurrentHashMap in JDK 1.8historical
JDK 1.8 ConcurrentHashMap combines synchronized, CAS, arrays, linked lists, and red-black trees for thread-safe access. These notes trace execution through methods such as putVal.
- 6.30 Producer-Consumerhistorical
Producers and consumers wait when conditions are unmet and wake one another when work can proceed. These notes compare wait/notify and two-Condition approaches.
- 6.31 Nonfair ReadWriteLockhistorical
These notes follow ReentrantReadWriteLock source code to examine nonfair read-write lock acquisition and direct acquisition attempts.
- 6.32 Nonfair Semaphorehistorical
A nonfair semaphore allows direct competition for permits. These notes trace acquisition and waiting through NonfairSync.
- 6.33 Thread.sleephistorical
After Thread.sleep ends, a thread can compete for the CPU again but is not guaranteed immediate execution. These notes illustrate that distinction with a timing example.
- 6.34 Nonfair Lockhistorical
A nonfair lock allows threads to attempt acquisition when the lock becomes free without requiring arrival order. These notes trace NonfairSync.lock.