Skip to content

Instantly share code, notes, and snippets.

@algrebe
Created April 18, 2016 15:10
Show Gist options
  • Save algrebe/18d35a2f330a85269e494969d5d0bbf1 to your computer and use it in GitHub Desktop.
Save algrebe/18d35a2f330a85269e494969d5d0bbf1 to your computer and use it in GitHub Desktop.
checking goroutines on a system
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