Go Max Procs
package main
import (
"fmt"
"runtime"
)
func main() {
totalThread := runtime.GOMAXPROCS(-1)
fmt.Println("Total Thread", totalThread)
totalCpu := runtime.NumCPU()
fmt.Println("CPU", totalCpu)
totalGoroutine := runtime.NumGoroutine()
fmt.Println("Num Goroutine", totalGoroutine)
runtime.GOMAXPROCS(20)
totalThread2 := runtime.GOMAXPROCS(-1)
fmt.Println("Total Thread", totalThread2)
totalCpu2 := runtime.NumCPU()
fmt.Println("CPU", totalCpu2)
totalGoroutine2 := runtime.NumGoroutine()
fmt.Println("Num Goroutine", totalGoroutine2)
}Last updated