Skip to content

Instantly share code, notes, and snippets.

@supr
Created May 27, 2011 22:10
Show Gist options
  • Save supr/996289 to your computer and use it in GitHub Desktop.
Save supr/996289 to your computer and use it in GitHub Desktop.
Simple Gorotine test
package main
import (
"fmt"
"time"
"rand"
"runtime"
)
func main() {
runtime.GOMAXPROCS(4)
times := 26
ch := make(chan bool)
for i := 0; i < times; i++ {
go func(x int) {
time.Sleep(rand.Int63n(4e9))
fmt.Printf("%c ", x+65)
ch <- true
}(i)
}
for i := 0; i < times; i++ {
<-ch
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment