Skip to content

Instantly share code, notes, and snippets.

Created December 27, 2012 05:35
Show Gist options
  • Save anonymous/4385719 to your computer and use it in GitHub Desktop.
Save anonymous/4385719 to your computer and use it in GitHub Desktop.
golang channel test sample 1
package main
import (
"runtime"
"fmt"
)
func test(c chan bool, b bool) {
x := 0.0
for i := 0.0 ; i < 10000000 ; i++ {
x += i
}
println(x)
if b {
c <- true
}
}
func main() {
runtime.GOMAXPROCS(2)
c := make(chan bool)
for i := 0 ; i < 50 ; i ++ {
go test(c, i == 49)
}
fmt.Println(<-c)
// <-c
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment