简体   繁体   English

使用pthread_cond_broadcast进行并行执行?

[英]Parallel Execution with pthread_cond_broadcast?

I would like to use pthread_cond_broadcast() to wake up all threads that is waiting for the same condition. 我想使用pthread_cond_broadcast()来唤醒等待相同条件的所有线程。

However, it seems like those threads can't really run in parallel because they have to share the same mutex. 但是,看起来这些线程并不能真正并行运行,因为它们必须共享相同的互斥锁。

Am I right? 我对吗? Or there is a way to do so? 或者有办法这样做?

Thanks in advance. 提前致谢。

每个线程必须在唤醒时获取锁,但如果紧接着工作可以并行进行,那么只需在最安全的时间点释放锁即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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