diff --git a/be/src/util/threadpool.cpp b/be/src/util/threadpool.cpp index c965e388c83506..75117ae0a9b3ea 100644 --- a/be/src/util/threadpool.cpp +++ b/be/src/util/threadpool.cpp @@ -292,9 +292,12 @@ Status ThreadPool::init() { } _pool_status = Status::OK(); - // create thread failed should not cause threadpool init failed, - // because thread can be created later such as when submit a task. - static_cast(try_create_thread(_min_threads)); + { + std::lock_guard l(_lock); + // create thread failed should not cause threadpool init failed, + // because thread can be created later such as when submit a task. + static_cast(try_create_thread(_min_threads)); + } // _id of thread pool is used to make sure when we create thread pool with same name, we can // get different _metric_entity