Skip to content

Latest commit

 

History

70 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Concurrency Modern 2026

Learning journey through modern Java concurrency, based on:

  • Java Concurrency in Practice — Brian Goetz et al.
  • Modern Concurrency in Java — A N M Bazlur Rahman
  • Java Structured Concurrency — Anghel Leonard
  • Understanding Java Virtual Threads — Fu Cheng

Structure

docs/         → Markdown notes (migrating to Astro later)
docs/images/  → Mermaid diagrams (PNG)
src/          → Code examples and demos
exercises/    → Self-test questions per chapter

📚 Notes

Chapter Source Doc
Ch. 3 — Sharing Objects JCiP docs/chapter-iii-shared-objects.md
Ch. 16 — The Java Memory Model JCiP docs/chapter-xvi-the-java-memory-model.md

💻 Code Examples

Sharing Objects (dev.concurrency.sharingobjects)

File Topic
GuardedObjectExample Guarded-by pattern
ThreadLocalDemo ThreadLocal usage and cleanup
SharedThreadSafeExample Thread-safe shared state
ImmutableUser Immutability with defensive copies
TryLockRetryExample tryLock with random backoff
ThreadConfinedExample Thread confinement
SharedReadOnlyExample Read-only shared data

Memory Model (dev.concurrency.memorymodel)

File Topic
VolatilePiggybackDemo Piggybacking visibility on volatile
SafePublicationDemo 4 safe publication idioms
UnsafePublicationDemo Broken singleton + 3 fixes

🧪 Exercises

Self-test questions organized by chapter — see exercises/README.md.

Chapter Questions Topics
Ch. III — Shared Objects 8 Publication/escape, ThreadLocal, deadlock/livelock
Ch. XVI — Java Memory Model 9 Piggybacking, safe publication, happens-before, join()

🖼️ Diagrams

Diagram Topic
happens-before-visibility Happens-before visibility between threads
join-happens-before-chain join() happens-before chain (Writer → Main → Reader)
join-does-not-order-threads join() does NOT order threads relative to each other
join-as-happens-before join() as a happens-before edge
join-vs-safe-publication join() vs safe publication mechanisms
static-initializer-vs-static-method static final (class loading) vs static method (no sync)
trylock-retry-sequence tryLock retry with random backoff sequence

🗺️ Chronological Study Plan

Phase I: Foundations (The Physics)

  • Java Concurrency in Practice (JCiP)
    • Ch. 3: Sharing Objects
    • Ch. 16: The Java Memory Model

Phase II: The Mechanics (The Shift)

  • Modern Concurrency in Java (Bazlur Rahman)
    • Ch. 4: Virtual Threads ← start here (practical "what and how")
    • Ch. 7: Carrier Thread Pinning ← read after Fu Cheng (makes mechanical sense)
  • Understanding Java Virtual Threads (Fu Cheng)
    • The Scheduler & Continuations ← read between Ch.4 and Ch.7 (the "why")

Phase III: The Architecture (Patterns)

  • Java Structured Concurrency (Anghel Leonard)
    • Ch. 2: StructuredTaskScope
    • Ch. 5: Scoped Values

About

Learning journey through modern Java concurrency: virtual threads, structured concurrency, JMM, and more

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages