Skip to content

Instantly share code, notes, and snippets.

@bradfitz
Created November 22, 2019 21:59
Show Gist options
  • Select an option

  • Save bradfitz/233894f4aec11b221cb06abd8489d2e4 to your computer and use it in GitHub Desktop.

Select an option

Save bradfitz/233894f4aec11b221cb06abd8489d2e4 to your computer and use it in GitHub Desktop.
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