Gosched()函数用于让出 CPU 时间,让其他 goroutine拥有运行的机会。其原理是将当前goroutine放回到队列中,等待下一次调度。
runtime.Gosched()
终止当前的goroutine,提前执行所有defer函数。
runtime.Goexit()
GC执行一次垃圾回收。
runtime.GC()
返回当前的goroutine数。
runtime.NumGoroutine()
本文分享自 作者个人站点/博客 前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!