Created
March 27, 2016 19:57
-
-
Save collinvandyck/147d87a5a0fae95c023f to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| "time" | |
| "runtime" | |
| ) | |
| func loopit() { | |
| for { | |
| select { | |
| case <- time.After(10 * time.Millisecond): | |
| } | |
| } | |
| } | |
| func main() { | |
| for i := 0; i < 100000; i++ { | |
| go loopit() | |
| } | |
| for _ = range time.Tick(time.Second) { | |
| numGoroutine := runtime.NumGoroutine() | |
| fmt.Println("Num goroutines:", numGoroutine) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment