Last active
February 6, 2020 22:57
-
-
Save shal/ec7763c59530ddd14525476fc5123b55 to your computer and use it in GitHub Desktop.
The issue of Go
This file contains 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 cpuIntensive(p *int) { | |
for i := 1; i <= 100000000000; i++ { | |
*p = i | |
} | |
} | |
func main() { | |
runtime.GOMAXPROCS(1) | |
x := 0 | |
go cpuIntensive(&x) | |
time.Sleep(100 * time.Millisecond) | |
fmt.Printf("x = %d.\n", x) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment