08/01/14 18:00:45
【OS】Windows Vista Ultimate
【言語】C++
【実行環境】Visual C++ 2005 Professional, C++ Boost Library 1.34.1
【その他突起する事項】なし
bool shouldExit_;
istream &is;
void handler()
{
while(!shouldExit_)
{
string str;
is >> str;
}
}
handler関数がthreadのコールバック関数になるのですが
この関数を終了させようとしてshouldExit_にtrueを代入しても
入力が内場合、入力演算子を使用しているところでずっと待機してしまいます。
このスレッドを安全に終了させる方法はないでしょうか?