What is a race condition in Java?
A race condition occurs when two threads try to execute a method at the same time, but they donâ€™t interfere with each other because Javaâ€™s memory model ensures thread safety.
Thatâ€™s incorrect. A race condition happens when threads access shared resources concurrently and at least one thread modifies the resource, causing issues.
Can you explain why using `synchronized` can help prevent race conditions?