void workerFunc() //first thread
{
for (int x=0;x<30;x++) //count up to 29
{
cout << x << endl;
Sleep(1000); //one sec delay
}
}
void test() //second thread
{
for (int y=30;y<99;y++) //count up to 98
{
cout <<'\t'<< y << endl;
Sleep (1000); //delay one sec
}
}
int main(int argc, char* argv[])
{
cout << "Main started " << endl;
boost::thread workerThread(workerFunc); //start the 1st thread
boost::thread t1(test); //start the second thread
cin.get();
return 0;
}
您好,当 test()
线程的 y=35 时,我想暂停/中断 workerFunc()
中的线程 test ()
我怎样才能做到这一点?
我是一名优秀的程序员,十分优秀!