简体   繁体   中英

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. :-)

If you are using Win32, then you can use a manual-reset Event . Your parent thread would call SetEvent() and could wake up all child threads waiting for that object with a function such as WaitForSingleObject() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM