[Go] golang设置运行的cpu数

前端之家收集整理的这篇文章主要介绍了[Go] golang设置运行的cpu数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
package main
import(
	"fmt"
	"runtime"
)
func main() {
	cpuNum:=runtime.Numcpu()
	fmt.Println("cpuNum=",cpuNum)
	runtime.GOMAXPROCS(cpuNum)
}

  

猜你在找的Go相关文章