Includes solved 02-worker-pool and 09-safe-counter (mutex, atomic, sharded). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GbnJj9ZqEx9nUvzkjdwfMq
21 lines
327 B
Go
21 lines
327 B
Go
// PREDICT the output before running. Then: go run . — and try with an older
|
|
// toolchain mentally: what did this print before Go 1.22?
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"sync"
|
|
)
|
|
|
|
func main() {
|
|
var wg sync.WaitGroup
|
|
for i := 0; i < 3; i++ {
|
|
wg.Add(1)
|
|
go func() {
|
|
defer wg.Done()
|
|
fmt.Println(i)
|
|
}()
|
|
}
|
|
wg.Wait()
|
|
}
|