如何从子线程中唤醒主线程(当前由于调用 sleep() 函数而处于休眠状态)(子线程不会终止)?
我想让我的主线程等待来自子线程的信号,而不使用无限循环或任何其他消耗 CPU 能力的东西。
我发现的关于这个主题的唯一事情是提到主线程唤醒子线程,而不是相反。
最佳答案
如果您只想暂停线程,直到它从另一个线程接收到信号,这正是 pause function 的作用。是为了。
pause() causes the calling process (or thread) to sleep until a signal is delivered that either terminates the process or causes the invocation of a signal-catching function.
关于c - 将主线程从 sleep 中唤醒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51032418/