Module 14: Concurrency and Multithreading
Synchronization Mechanisms
Use synchronized blocks, ReentrantLock, and volatile fields correctly.
synchronized enforces mutual exclusion and provides happens-before ordering.
ReentrantLock offers timed locks, fairness, and manual control; always release in finally blocks.
volatile ensures visibility but not atomicity—use Atomic classes for compound actions.