Skip to content

Instantly share code, notes, and snippets.

@scbizu
Created May 30, 2016 11:20
Show Gist options
  • Save scbizu/b9b6610200a5966db540f87e58f6eb3b to your computer and use it in GitHub Desktop.
Save scbizu/b9b6610200a5966db540f87e58f6eb3b to your computer and use it in GitHub Desktop.
Test golang Maxprocs
package main
import (
"fmt"
// "runtime"
)
/*
*Question:
*Test GOMAXPROCS
*/
var ch0 chan int = make(chan int)
func testLoop() {
for i := 0; i < 100; i++ {
fmt.Printf("%d ", i)
}
fmt.Print("\n")
fmt.Println("GoR finished")
ch0 <- 1
}
func main() {
// runtime.GOMAXPROCS(1)
go testLoop()
go testLoop()
for i := 0; i < 2; i++ {
<-ch0
}
fmt.Println("finished")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment