@@ -13,14 +13,14 @@ import (
|
||||
// Note that a WaitGroup must be passed to functions by
|
||||
// pointer.
|
||||
func worker(id int, wg *sync.WaitGroup) {
|
||||
// On return, notify the WaitGroup that we're done.
|
||||
defer wg.Done()
|
||||
|
||||
fmt.Printf("Worker %d starting\n", id)
|
||||
|
||||
// Sleep to simulate an expensive task.
|
||||
time.Sleep(time.Second)
|
||||
fmt.Printf("Worker %d done\n", id)
|
||||
|
||||
// Notify the WaitGroup that this worker is done.
|
||||
wg.Done()
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
39bbc00ecd87888761d480666e95d8b2c2a2a589
|
||||
oBOGrV0n2Y2
|
||||
fd77f5122e6df1669c0a2e0d2c4dfbd30631c21f
|
||||
7mWXl0yVe6I
|
||||
|
||||
Reference in New Issue
Block a user