// How many threads have arrived to the barrier shared count := 0 // Protects the increment of the count shared can_access_count := semaphore(1) // Locked (0) until all threads arrive, then it is unlocked (1) shared barrier := semaphore(0) main: thread_count := read_integer() create_threads(thread_count, secondary) secondary: Statement A // Adapt rendezvous solution here // Statement B can be only executed until all threads have run Statement A Statement B