package main
import (
//"time"
"runtime"
"fmt"
)
func main() {
//time.Sleep(100 * time.Millisecond)//By adding this number of goroutine increases
fmt.Println(runtime.NumGoroutine())
}
Run Code Online (Sandbox Code Playgroud)
我试图找出程序中的goroutines数量.我的代码在这里.编码时我注意到默认的goroutines数是4.
为了我:
还有什么?
通过添加time.Sleep(上图),goroutines的数量增加到5.这是什么原因?