Weerasak Chongnguluam
Feb 20 · 1 min read
func main() {
var wg sync.WaitGroup

for i := 0; i < 20; i++ {
wg.Add(1)
go func(k int) {
defer wg.Done()
for j := 0; j < 3000000; j++ {
if j%3000 == 0 {
fmt.Println(k, j)
}
}
}(i)
}

wg.Wait()
}

    Weerasak Chongnguluam

    Written by

    I’m a Programmer.

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade