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()
我怎样才能做到这一点?