Skip to content

Instantly share code, notes, and snippets.

@supr
Created May 27, 2011 22:36
Show Gist options
  • Save supr/996335 to your computer and use it in GitHub Desktop.
Save supr/996335 to your computer and use it in GitHub Desktop.
Simple Gorotine test using WaitGroup
package main
import (
"fmt"
"time"
"rand"
"sync"
"runtime"
)
func main() {
runtime.GOMAXPROCS(4)
wg := &sync.WaitGroup{}
times := 26
wg.Add(times)
for i := 0; i < times; i++ {
go func(x int) {
time.Sleep(4e9)
fmt.Printf("%c ", x+65)
wg.Done()
}(i)
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment