Skip to content

Instantly share code, notes, and snippets.

@shal
Last active February 6, 2020 22:57
Show Gist options
  • Save shal/ec7763c59530ddd14525476fc5123b55 to your computer and use it in GitHub Desktop.
Save shal/ec7763c59530ddd14525476fc5123b55 to your computer and use it in GitHub Desktop.
The issue of Go
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