When two threads update the same variable, like a shared counter, updates can be lost because count++ is not one step. synchronized lets only one thread at a time run the protected code, which fixes this race condition. Use it around small sections that read and write shared data. Locking too much makes threads wait and slows the program, and for simple counters an AtomicInteger is often better.