Foundations
Concurrency and correctness
Protect compound operations, not just individual fields.
Understand the problem
Identify shared mutable state and the invariant spanning it. Use a lock or atomic operation around the complete check-and-update. Avoid holding locks during network calls.
Make it concrete
Checking one remaining seat and decrementing it must be one protected action.
Trade-offs and pitfalls
Coarse locks simplify correctness but reduce parallelism.
Check your understanding
Describe a deadlock and a consistent lock-ordering rule.
Practice this topic