runtime.Gosched()

Gosched()函数用于让出CPU时间,让其他goroutine拥有运行的机会。其原理是将当前goroutine放回到队列中,等待下一次调度。

runtime.Gosched()

runtime.Goexit()

终止当前的goroutine,提前执行所有defer函数。

runtime.Goexit()

runtime.GC()

GC执行一次垃圾回收。

runtime.GC()

runtime.NumGoroutine()

返回当前的goroutine数。

runtime.NumGoroutine()