A race condition occurs when multiple threads access shared data concurrently and at least one thread modifies it. Without proper synchronization, the final result becomes unpredictable.
Without Lock: Multiple threads read-modify-write the counter simultaneously, causing lost updates.
With Lock: Only one thread can access the critical section at a time, ensuring correctness.