Created
April 18, 2016 15:10
-
-
Save algrebe/18d35a2f330a85269e494969d5d0bbf1 to your computer and use it in GitHub Desktop.
checking goroutines on a system
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" | |
"time" | |
) | |
func do() { | |
for { | |
} | |
} | |
const DURATION = 20 * time.Second | |
func main() { | |
// every DURATION spawn a goroutine | |
for { | |
fmt.Printf("Spawning...\n") | |
go do() | |
fmt.Printf("%d routines...\n", runtime.NumGoroutine()) | |
time.Sleep(DURATION) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment