package main import ( "fmt" "runtime" "runtime/debug" "runtime/pprof" "time" ) func main() { runtime.GOMAXPROCS(1) debug.SetMaxThreads(10) fmt.Println("start") threadProfile := pprof.Lookup("threadcreate") fmt.Printf(" init threads counts: %d\n", threadProfile.Count()) go func() { for { } fmt.Println("end goruntine") }() time.Sleep(3 * time.Second) fmt.Printf(" end threads counts: %d\n", threadProfile.Count()) fmt.Println("end") }