go设置使用多少个cpu

package main

import (
    "fmt"
    "runtime"
)

func main() {
    n := runtime.NumCPU()
    fmt.Print(n)
    runtime.GOMAXPROCS(n - 1) //设置cpu运行的数目
}




posted @ 2019-12-19 20:26  离地最远的星  阅读(827)  评论(0编辑  收藏  举报