1
JavaAdvanced#concurrency
A race condition occurs when multiple threads access shared mutable state concurrently and the outcome depends on timing. Prevent it with synchronization, locks, atomic classes, or immutable/thread-confined data.
// Without synchronization, count++ isn't atomic AtomicInteger count = new AtomicInteger(0); count.incrementAndGet(); // thread-safe increment