3 ms·
Since the post doesn't really explain it, the race condition is because when notify_all is called there might be a thread that already has acquired the lock and
by thayne 3y ago
Since the post doesn't really explain it, the race condition is because when notify_all is called there might be a thread that already has acquired the lock and is running, so that thread won't get the notification, and might not wake up on the next iteration.
I think wrapping the call to notify_all in the lock would also fix the race condition.