concurrency
threads, races, locks, the memory model, executors and virtual threads.
- 01threadsstarting threads, their lifecycle, and the six states.
- 02race conditionstwo threads, one counter++, and a lost update. interleave them yourself.
- 03synchronized and monitorsevery object has a lock. entry sets, reentrancy, and what it guards.
- 04wait and notifyguarded blocks, spurious wakeups, and why you should use something else.
- 05the java memory modelhappens-before, volatile, reordering, and safe publication.
- 06atomics and CAScompare-and-swap loops, AtomicInteger, LongAdder, and ABA.
- 07locks and AQSReentrantLock, ReadWriteLock, StampedLock, and the queue under all of them.
- 08executors and thread poolscore size, max size, the queue, and rejection. play with a pool.
- 09CompletableFutureasync pipelines: thenApply, thenCompose, allOf, and error handling.
- 10fork/join and work stealingsplit work recursively, idle threads steal from busy ones.
- 11concurrent collectionsConcurrentHashMap, CopyOnWriteArrayList, BlockingQueue.
- 12synchronizersCountDownLatch, CyclicBarrier, Semaphore, Phaser.
- 13deadlocks and livenessdeadlock, livelock, starvation. the dining philosophers, live.
- 14virtual threadsjava 21+millions of threads, mounted on a few carriers.
- 15structured concurrency and scoped valuesjava 25+task trees that cancel together, and ThreadLocal's replacement.
- 16testing concurrent codewhy your test passed 1000 times and failed in prod. jcstress.