Advanced
Java Concurrency
Correct first. Then fast.
Threads, the memory model, synchronized and volatile, locks, executors, CompletableFuture, concurrent collections and virtual threads — with the bugs each one exists to prevent, and the ones each one introduces.
9 lessons written3 modules~2h reading✓ interview set✓ quiz
After this course you can
- Explain happens-before and use it to decide whether a data race exists
- Size an executor for CPU-bound and I/O-bound work and know why the answers differ
- Compose asynchronous work with CompletableFuture without losing exceptions
- Diagnose a deadlock, a livelock and thread-pool exhaustion from a thread dump
Curriculum
9 lessons · outlined lessons show their plan01
Threads and the Java Memory ModelWhat a thread is to the OS and the JVM, why two threads can disagree about a variable, and happens-before as the only rule that matters.13 minsynchronized and volatileMonitors, intrinsic locks, reentrancy, visibility versus atomicity, and the double-checked locking that was broken before Java 5.12 minLocks and conditionsReentrantLock, tryLock with timeout, fairness, ReadWriteLock, StampedLock, and Condition for the producer-consumer you would otherwise get wrong.11 minAtomics and lock-free thinkingcompare-and-swap, AtomicInteger, LongAdder, and why lock-free is a property of an algorithm, not of a class name.10 minFoundations
02
Executors and thread poolsThreadPoolExecutor's seven parameters, queue choice, rejection policies, and the pool that quietly swallowed every exception.11 minCompletableFutureComposition, exception propagation, thenApply versus thenCompose, timeouts, and the default pool you must not run blocking work on.10 minConcurrent collectionsConcurrentHashMap's guarantees, CopyOnWriteArrayList, BlockingQueue, and the compound operation that is not atomic even on a concurrent map.12 minExecutors and futures
03
Virtual threads in servicesThread-per-request without the pool, what pins a virtual thread, and how to migrate a Spring service without a rewrite.13 minDiagnosing concurrency bugsReading a thread dump, finding the deadlock cycle, spotting pool exhaustion, and the tests that reproduce a race on purpose.12 min