CSE Roadmap

Core tier · about 4 hours · 6 parts

Part 1 of 6 · 1 min read

Why this page comes third in Level 5

In this module you will

  • Explain a race condition and the check-then-act pattern.
  • Make a compound action atomic with synchronized or an atomic class.
  • Explain why a read also needs synchronization (visibility).
  • Design a thread-safe class by confinement, immutability or delegation, and document its policy.
  • Avoid lock-ordering deadlock.

Many LLD case studies end with "what if two users book the same seat at once". Parking lots, ticket booking, rate limiters and caches all share data between threads. This page gives the working rules. It is a first pass and not a full course in concurrency. The sources are "Java Concurrency in Practice" (JCIP) chapters 2, 3, 4 and 10, and "Effective Java" (EJ) Items 78 to 82. Code was compiled and run before it was written here. Numbers marked "made up" only show the idea.