Checkpoint synchronization: Difference between revisions
→{{header|Go}}: serialized output
m (→{{header|Go}}: typo) |
(→{{header|Go}}: serialized output) |
||
Line 345:
import (
"
"os"
"rand"
"sync"
Line 353 ⟶ 354:
const nMech = 5
const detailsPerMech = 4
var l = log.New(os.Stdout, "", 0)
func main() {
Line 368 ⟶ 371:
complete.Wait()
// checkpoint reached
}
}
Line 387 ⟶ 390:
dword = "detail"
}
go worker(a, c, contract, id)
nDetails -= contract
Line 396 ⟶ 399:
// some random time it takes for this worker to assemble a detail
assemblyTime := 5e8 + rand.Int63n(5e8)
for i := 0; i < contract; i++ {
<-a
time.Sleep(assemblyTime)
c.Done()
}
}</lang>
Output:
|