Mutual Exclusion is a technique to solve this problem:
Race condition is prevented by ensuring that no two concurrent processes are in the critical phase
(in our case: accessing and changing global data)
at the same time!
We need a Mutual Exclusion Lock:
m = threading.Lock()
acquiring a lock:
m.acquire()
releasing a lock:
m.release()