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.
所以我在 C 中的问题是:与在循环中使用 pthread Join 相比,使用 pthread 屏障(init 和 wait..etc)基本上有什么区别(可能是优点和缺点)。
所以说我在一个循环中创建了 10 个线程,然后在我想要屏障的地方,我放置了一个循环来为所有线程执行 Join。那岂不是也起到了屏障的作用?
请说清楚。谢谢!
pthread_join()阻塞调用线程,直到加入线程退出。相反,屏障允许所有线程继续运行。
pthread_join()