Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用 pthread_cond_broadcast() 来唤醒所有等待相同条件的线程。
但是,这些线程似乎不能真正并行运行,因为它们必须共享相同的互斥体。
我对吗?或者有办法做到这一点?
提前致谢。
每个线程在唤醒时都必须获取锁,但如果紧随其后的工作可以并行进行,那么只需在安全的最早时间释放锁即可。