Problem Statement
Which synchronization primitive ensures both mutual exclusion and prevents data race in a multithreaded program?
Explanation
A mutex lock is designed to provide mutual exclusion by allowing only one thread to hold the lock and enter a critical section at a time, thus preventing data races on shared data. Barriers wait for all threads, spin-locks busy-wait and semaphores may allow more than one holder unless used as binary; so understanding the subtle differences is important for interviews.
