What is race condition?
A race condition is a situation in which two or more threads or
processes are reading or writing some shared data, and the final
result depends on the timing of how the threads are scheduled.
Race conditions can lead to unpredictable results and subtle
program bugs. A thread can prevent this from happening by locking
an object. When an object is locked by one thread and another
thread tries to call a synchronized method on the same object,
the second thread will block until the object is unlocked.