2 ms·
> To kill the thread, set the stop flag and cond_signal the condvar This is a race condition. When you "spin" on a condition variable, the stop flag you check
by exDM69 1y ago
> To kill the thread, set the stop flag and cond_signal the condvar
This is a race condition. When you "spin" on a condition variable, the stop flag you check must be guarded by the same mutex you give to cond_wait.
See this article for a thorough explanation:
https://zeux.io/2024/03/23/condvars-atomic/ https://zeux.io/2024/03/23/condvars-atomic/