Created
May 30, 2016 11:20
-
-
Save scbizu/b9b6610200a5966db540f87e58f6eb3b to your computer and use it in GitHub Desktop.
Test golang Maxprocs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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