Barrier Synchronization
Barrier synchronization is a coordination mechanism in which a group of threads or processes must all reach a designated point in their execution before any of them may proceed beyond it. The barrier acts as a rendezvous: threads arriving early block and wait; when the last thread arrives, all are released simultaneously to continue. It is the concurrent programming equivalent of a group agreement: no one moves forward until everyone has caught up.
Barriers are essential in parallel computing algorithms that proceed in phases — for example, iterative numerical simulations where each phase depends on the results of the previous phase computed by all threads. Implementation typically uses a shared counter protected by a mutex or semaphore, though lock-free barrier designs exist for high-performance contexts. The primary risk is that a single slow thread can stall the entire group, making barrier synchronization unsuitable for workloads with highly variable per-thread execution times.
See also: Thread, Process, Concurrency, Mutex, Semaphore, Condition Variable, Parallel Computing, Lock-Free Programming