See a description of race conditions and dead ends.
Race conditions
A race condition occurs when two threads access a shared variable at the same time. The first thread reads the variable and the second thread reads the same value from the variable. Then the first thread and the second thread perform their operations on value, and they are involved in which thread can write the value of last to a common variable. The value of the stream that writes its value last is saved, since the stream is writing the value that the previous stream wrote.
Dead ends
A deadlock occurs when two threads each commit another variable at the same time, and then try to lock the variable so that the other thread is already locked. As a result, each thread stops executing and waiting for another to free the variable. Since each thread holds the variable that the other thread wants, nothing happens and the threads remain deadlocked.
source share