簡體   English   中英

std::thread::join 不返回

[英]std::thread::join not returning

我正在嘗試對我的程序進行多線程處理,並嘗試使用單獨的線程來運行特定的 function。 但是,每當我在所述線程上調用 join() function 時,它永遠不會返回,並且程序將停止響應。 我正在檢查線程是否可以連接。

這是我所擁有的:

static std::thread receiveThread = std::thread(&Server::receiveData, this);
if (receiveThread.joinable())
    {
        receiveThread.join();
        receiveThread = std::thread(&Server::receiveData, this);
    }

std::thread::join僅在線程(由線程包裝器擁有)返回后返回。 如果有問題的線程永遠不會返回,那么對std::thread::join的調用也永遠不會返回。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM