This lecture is about what a shared resource is in multithreaded applications, why race conditions and “lost updates” occur, and how to protect data using
synchronized. We will cover basic synchronization techniques (methods and blocks), talk about modern tools from
java.util.concurrent (
Lock,
ReentrantLock,
Semaphore, etc.), and look at practical examples with incrementing a counter and typical mistakes (non-atomic
i
++, wrong lock object, myths about
volatile).