Java Concurrency, Visualized
No walls of textbook jargon. Every topic starts with a clear everyday model, lets you predict and step through real JVM interleavings, translates Java lines into plain English, and drills the exact exam traps from Weeks 1–4 and your coursework — completely offline.
Course Mastery Progress (saved in this browser)
0%
0 / 6 modules completed
Exam Cram Mode is ON: Long walkthroughs and analogies are hidden across every page, leaving tight recaps, diagrams, exam traps, and comparison tables. Switch back to Full Read anytime in the top bar.
Course Concept Map — How Every Lecture Connects
Click any module node to inspect prerequisites & key traps
M3 · Weeks 2–3 · Ready
Thread Lifecycle & Monitor Coordination
Interactive 6-state thread machine, Predict-Before-Step KitchenWorker tracer, and a unified OrderCounter board with pinned Java lines and lost wake-up exploration.
Core Study Modules (Weeks 1–4 & Coursework)
Upcoming Syllabus Roadmap (Weeks 5–10)
Quick-Reference Java Concurrency Ledger
| Java Primitive | Primary Job | Ownership & Reentrancy | #1 Course Exam Trap |
|---|---|---|---|
| synchronized | Mutual exclusion + memory visibility on an object/class monitor. | Owned by entering thread; reentrant; auto-released on block exit/exception. | Static method locks Class.class; instance method locks this — they do not block each other. |
| volatile | Guarantees visibility across CPU caches (flushes to main memory). | No lock, no mutual exclusion. | volatile int count; count++; is still a race condition (not atomic). |
| wait() / notifyAll() | Condition coordination inside a synchronized monitor. |
Must hold that object's lock (else IllegalMonitorStateException); wait() releases only that lock. |
Using if instead of while (returns null on empty queue), or notify() causing a lost wake-up hang. |
| BlockingQueue | Thread-safe bounded/unbounded producer-consumer handoff (put/take). |
Internal locks & conditions managed by JDK. | Wrapping put()/take() in an extra synchronized method causes double-lock deadlock. |
| ReentrantLock | Explicit lock with tryLock(timeout), fairness, & multiple Conditions. |
Owned by locking thread; reentrant; manual release. | Forgetting lock.unlock() inside a finally block leaks the lock forever on exception. |
| Semaphore(N, fair) | Permit-based access control for N resources or cross-thread signaling. | No ownership (any thread can release()); not reentrant. |
Acquiring mutex before empty/full in 3-Semaphore Producer-Consumer causes deadlock. |