class Class {
public:
Class ();
private:
std::thread* updationThread;
};
构造函数:
Class::Class() {
updationThread = new std::thread(&someFunc);
}
在我的应用程序的某个时刻,我必须暂停该线程并调用一个函数,并且在执行该函数后我必须恢复该线程。假设它发生在这里:
void Class::aFunction() {
functionToBeCalled(); //Before this, the thread should be paused
//Now, the thread should be resumed.
}
我曾尝试使用另一个具有功能functionToBeCalled()
和用途的线程,thread::join
但由于某种原因无法做到这一点。
如何暂停一个线程或如何使用thread::join
暂停一个线程直到另一个线程完成?