I have this part of the code for executing three threads, where the second thread should abort when you press enter and print an exit message:
void input_val()
{
return;
}
void process_val()
{
try{
cout << "waiting for ENTER..." << endl;
boost::this_thread::sleep(boost::posix_time::milliseconds(200));
}
catch(boost::thread_interrupted&){
cout << "exit process thread" << endl;
return;
}
return;
}
void output_val()
{
}
int main()
{
char key_pressed;
boost::thread input_thread(boost::bind(&input_val));
boost::thread process_thread(boost::bind(&process_val));
boost::thread output_thread(boost::bind(&output_val));
cin.get(key_pressed);
process_thread.interrupt();
input_thread.join();
process_thread.join();
output_thread.join();
return 0;
}
The thread_process aborts to "ENTER", but does not print a message indicating that it exited the termination process. Can anyone suggest what might be the problem, because I had a similar program yesterday. Thank you in advance!
Nd_27 source
share