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.
程序有 n 个线程(图形着色,一个线程负责一个节点)执行相同的代码。如何以这样的方式制作一个同步点:在n个线程中的每一个都达到这个点之前,没有一个线程可以通过那个点?想法类似于当线程到达特定位置时递增的计数器。在 C# 中解决它的最佳方法是什么?
有多种方法可以做到这一点。
类System.Threading.Barrier(Fx4+) 似乎很合适,请参阅障碍介绍
System.Threading.Barrier