Created
October 17, 2012 15:43
-
-
Save jordanorelli/3906250 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 ( | |
"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