c++ condition variable notification not working as expected
问题 I'm trying to launch new threads as soon as work in previous worker_thread has started , but maybe ended or not. I've replaced started and ended work with time delays. My code is: #include <iostream> #include <string> #include <mutex> #include <condition_variable> #include <future> #include <atomic> #include <chrono> #include <thread> std::mutex m; std::condition_variable cv; bool started = false; void worker_thread() { std::unique_lock<std::mutex> lk(m); static std::atomic<int> count(1); std