[英]How I get child threads wait on a condition and all waked up by one call from parent thread?
子线程进入睡眠状态,父线程可以调用某些例程来唤醒所有子线程来运行吗?
If you're using POSIX threads (pthreads), then pthread_cond_wait
and (in your case) pthread_cond_broadcast
are your friends. 如果您使用的是POSIX线程(pthread),那么
pthread_cond_wait
和(在您的情况下) pthread_cond_broadcast
是您的朋友。 :-) :-)
If you are using Win32, then you can use a manual-reset Event . 如果使用的是Win32,则可以使用手动重置的Event 。 Your parent thread would call
SetEvent()
and could wake up all child threads waiting for that object with a function such as WaitForSingleObject()
. 您的父线程将调用
SetEvent()
并可以使用诸如WaitForSingleObject()
类的功能唤醒所有等待该对象的子线程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.