Skip to content

Instantly share code, notes, and snippets.

@jumanji27
Created April 11, 2025 14:03
Show Gist options
  • Save jumanji27/0ba697e133e30f0380483ced7b18ec9f to your computer and use it in GitHub Desktop.
Save jumanji27/0ba697e133e30f0380483ced7b18ec9f to your computer and use it in GitHub Desktop.
go-problem-4.go
package main
import (
"fmt"
"sync"
"time"
)
func worker(id int, wg *sync.WaitGroup) {
defer wg.Done()
fmt.Printf("Worker %d is working\n", id)
time.Sleep(5 * time.Second)
}
func main() {
var wg sync.WaitGroup
for i := 1; i <= 10; i++ {
wg.Add(1)
go worker(i, &wg)
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment