栅栏 这个词源于 jdk 1.5 中新增了一个类: CyclicBarrier

    A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released. A CyclicBarrier supports an optional Runnable command that is run once per barrier point, after the last thread in the party arrives, but before any threads are released. This barrier action is useful for updating shared-state before any of the parties continue.

    一种同步辅助工具,它允许一组线程都等待彼此到达一个共同的障碍点。CyclicBarriers (个人觉得: 应该翻译为循环屏障)在涉及固定大小的线程组的程序中很有用,这些线程群必须偶尔相互等待。该屏障称为循环(Cyclic),因为它可以在释放等待线程后重复使用。

    这里使用 go 实现一下

    java 官网示例: