Created
May 19, 2025 07:09
-
-
Save antonkalik/6ee06aa7a11db9050a60d1187c896e48 to your computer and use it in GitHub Desktop.
goroutine
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 characters
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