Ask HN: Can a mutex have a race condition?
But then, if there’s a way to lock a mutex so that it’s impossible for two threads to do it at the same time, why not use that mechanism to modify whatever shared variable is in question?
I imagine that pthread or <insert other threading library>’s provided mutex is, internally, an integer which is set to 1 or 0 depending on the mutex’s state.
if i want to share an integer from my program with another thread, why cant I just use whatever is used by the mutex?