Skip to content

Instantly share code, notes, and snippets.

@antonkalik
Created May 19, 2025 07:09
Show Gist options
  • Save antonkalik/6ee06aa7a11db9050a60d1187c896e48 to your computer and use it in GitHub Desktop.
Save antonkalik/6ee06aa7a11db9050a60d1187c896e48 to your computer and use it in GitHub Desktop.
goroutine
package main
import (
"fmt"
"sync"
"time"
)
func fakeWork(wg *sync.WaitGroup, id int) {
defer wg.Done()
time.Sleep(100 * time.Millisecond)
}
func main() {
start := time.Now()
var wg sync.WaitGroup
wg.Add(10)
for i := 0; i < 10; i++ {
go fakeWork(&wg, i)
}
wg.Wait()
fmt.Println("Go Concurrency Time:", time.Since(start))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment