On Wed, Apr 10, 2019 at 4:52 AM <mountain...@gmail.com> wrote: > > My macos has 4 cores, but i start 3 goroutines, 2 sub goroutines, 1 main > goroutine. > After main goroutine exec 3 times output, triggering gc causes gcwaiting=1. > Finally all goroutine blocking > > package main > > import ( > "fmt" > "log" > "net/http" > _ "net/http/pprof" > "runtime" > > // "runtime" > "time" > ) > > func deadloop() { > for { > } > } > func main() { > go func() { > log.Println(http.ListenAndServe("localhost:6060", nil)) > }() > > go deadloop() > > i := 3 > for { > time.Sleep(time.Second * 1) > i-- > fmt.Println("I got scheduled!") > if i == 0 { > runtime.GC() //will set gcwaiting=1, causes other goroutines not to be > scheduled > } > } > }
I'm not sure quite what you are asking, but the garbage collector has to briefly stop all goroutines twice each cycle, as described in the comment in runtime/mgc.go. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.