June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func worker(part string) {
|
||||
log.Println(part, "worker begins part")
|
||||
time.Sleep(time.Duration(rand.Int63n(1e6)))
|
||||
log.Println(part, "worker completes part")
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
var (
|
||||
partList = []string{"A", "B", "C", "D"}
|
||||
nAssemblies = 3
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
for c := 1; c <= nAssemblies; c++ {
|
||||
log.Println("begin assembly cycle", c)
|
||||
wg.Add(len(partList))
|
||||
for _, part := range partList {
|
||||
go worker(part)
|
||||
}
|
||||
wg.Wait()
|
||||
log.Println("assemble. cycle", c, "complete")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue