Object-Oriented Programming · Apple · Hard
Build a reusable synchronization point for threads, CyclicBarrier(parties), that lets a fixed group of threads rendezvous again and again. Provide a wait() method. In every round, exactly parties threads call it. Each caller except the last one must block until the final thread of that round shows up; once that last thread arrives, every blocked thread in the round is released and may continue. The barrier has to work across many consecutive rounds, so a thread that races…