/* DTU 02158 Concurrent Programming Mandatory Assignment 4 */ package main import ( "fmt"; "sync") const N = 10 const Iter = 5 var printer sync.Mutex; type Barrier struct { count int; release *sync.Cond } func (b *Barrier) init() { b.count = 0 b.release = sync.NewCond(&sync.Mutex{}) } func (b *Barrier) sync() { b.release.L.Lock() defer b.release.L.Unlock() b.count++ if b.count==N { b.count = 0; b.release.Broadcast(); printBar() } else { b.release.Wait() // NO Spurious wakeups in Go!! } } func printBar() { printer.Lock() defer printer.Unlock() for k := 0; k