Created
November 22, 2019 21:59
-
-
Save bradfitz/233894f4aec11b221cb06abd8489d2e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "flag" | |
| "fmt" | |
| "runtime" | |
| ) | |
| func main() { | |
| var cpus = flag.Int("cpus", runtime.NumCPU()*2, "number of threads to spin") | |
| flag.Parse() | |
| fmt.Println("Spinning..") | |
| for i := 0; i < *cpus; i++ { | |
| go func() { | |
| for { | |
| n := 0 n++ } | |
| }() | |
| } | |
| select {} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment