Skip to content

Instantly share code, notes, and snippets.

@luandevpro

luandevpro/main.go

Created Aug 2, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.