How to think Data race: an issue when data are accessible by multi-thread. How to solve? -> Locks, Mutual exclusion locks (a.k.a., Mutex locks) Mutex Mutex = Mutual exclution lock = a thread locks exclusively other threads until done. (Binary) Semaphor and Mutex https://stackoverflow.com/a/86021/9923806 Mutual exclusion semaphores are used to protect shared resources (data structure, file, etc..). A Binary semaphore should be used for Synchronization. Critical section https://en.