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
暂停线程,直到其他完成?
那是什么其他的线程在做什么?你可以玩“someFunc”的身体吗? “暂停”线程不是正常操作。 – user7116
STL不提供此。在Windows中,您可以使用SuspendThread。 – cdoubleplusgood
@ user7116我可以。我想这样做的原因是因为当'functionToBeCalled()'和线程一起工作时,我遇到了内部问题。 – khajvah