Created
June 26, 2018 17:00
-
-
Save thekvs/7f65e2870c649d8ae0e0dcbeff629ef8 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 ( | |
"net/http" | |
"runtime" | |
) | |
func cpuEater() { | |
var counter uint64 | |
for { | |
counter += 1 | |
if counter == 0xfffffffffffffffe { | |
counter = 0 | |
} | |
runtime.Gosched() | |
} | |
} | |
func handler(w http.ResponseWriter, r *http.Request) { | |
w.Write([]byte("Hello World!")) | |
} | |
func main() { | |
for i := 0; i < runtime.NumCPU(); i++ { | |
go cpuEater() | |
} | |
http.HandleFunc("/", handler) | |
if err := http.ListenAndServe(":8080", nil); err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment