Created
August 2, 2020 06:44
-
-
Save luandevpro/d04ae3cfcda663bff9e6a637b4cf1ae1 to your computer and use it in GitHub Desktop.
This file contains 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 characters
package main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func WellCome1(s string) { | |
for i := 0; i < 5; i++ { | |
fmt.Println(s, ":", i) | |
} | |
wg.Done() | |
} | |
func WellCome2(s string) { | |
for i := 0; i < 5; i++ { | |
time.Sleep(100*time.Millisecond) | |
fmt.Println(s, ":", i) | |
} | |
wg.Done() | |
} | |
var wg sync.WaitGroup | |
func main() { | |
wg.Add(2) | |
go WellCome1("wellcome1") | |
go WellCome2("wellcome2") | |
wg.Wait() | |
time.Sleep(200 * time.Millisecond) | |
fmt.Println("hello main ") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment