Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created September 6, 2012 21:59
Show Gist options
  • Save jordanorelli/3660681 to your computer and use it in GitHub Desktop.
Save jordanorelli/3660681 to your computer and use it in GitHub Desktop.
CPU-blocking test
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
// THIS is totally required; without it, you're blocking the CPU regardless
// of whether you use LockOSThread or not.
runtime.GOMAXPROCS(4)
// arbitrary CPU-blocking function
go func() {
// THIS appears to be optional; I'm not really sure how this works.
// runtime.LockOSThread()
x := 0
for {
x += 1
}
}()
for {
fmt.Println("hey")
time.Sleep(time.Second)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment