When two processes sharing a common variable try to update it
simultaneously, one cannot predict the output of it, this is the
race condition.A thread while updating the variable can be
preempted by another thread and update it differently .This is why
Synchronization mechanisms are used.
Process 1: X=X+1
Process 2: X=X+2
Machine code is
ADD EAX , 1
While process1 is executing second line it could be preempted ..And process2 takes turn so , MEMORY_X contains value 7,.Now Process1 comes back and starts the remaining lines of code .The memory then contains value 6.
Which is the final answer. But we should have got a value of 8 instead