diff --git a/muduo/net/EventLoopThread.cc b/muduo/net/EventLoopThread.cc index c1b6fa56d..4a2899ac0 100644 --- a/muduo/net/EventLoopThread.cc +++ b/muduo/net/EventLoopThread.cc @@ -32,6 +32,9 @@ EventLoopThread::~EventLoopThread() // still a tiny chance to call destructed object, if threadFunc exits just now. // but when EventLoopThread destructs, usually programming is exiting anyway. loop_->quit(); + } + // In case `threadFunc` finished before destructing. + if (thread_.started()) { thread_.join(); } }