我在一個單獨的執行緒中有一個 while 回圈正在監聽stdin,等待來自另一個行程的文本。當我的程式退出時,我想退出這個while回圈并加入執行緒。
std::string line;
while (std::getline(std::cin, line))
{
std::stringstream linestream(line);
}
uj5u.com熱心網友回復:
這是分離執行緒可能合適的罕見情況之一。當程式退出時,執行緒將被終止。
std::thread thr(whatever);
thr.detach();
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/504230.html
