diff --git a/src/Common/ThreadPool.cpp b/src/Common/ThreadPool.cpp index 3ddc68f70fae..054ee536b80c 100644 --- a/src/Common/ThreadPool.cpp +++ b/src/Common/ThreadPool.cpp @@ -665,10 +665,14 @@ void ThreadPoolImpl::worker(typename std::list::iterator thread_ --scheduled_jobs; calculateDesiredThreadPoolSizeNoLock(); - job_finished.notify_one(); + if (scheduled_jobs == 0) { - job_finished.notify_all(); + job_finished.notify_all(); // one of the threads can be waiting in wait() for that condition + } + else + { + job_finished.notify_one(); } }