Created
January 13, 2020 20:45
-
-
Save prabaprakash/d3f192587cd86477d558921f8295b056 to your computer and use it in GitHub Desktop.
Revisions
-
prabaprakash created this gist
Jan 13, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ package main import ( "fmt" "time" "sync" ) var wg sync.WaitGroup func say(s string) { for i := 0; i < 5; i++ { time.Sleep(100 * time.Millisecond) fmt.Println(s) } wg.Done() // <=> wg.Add(-1) } func main() { wg.Add(2) // register two tasks. go say("world") say("hello") fmt.Println("re") wg.Wait() }