Skip to content

Instantly share code, notes, and snippets.

@ashishtiwari1993
Created February 28, 2020 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashishtiwari1993/00b2a56ac8f5b39d3229d723e58815bc to your computer and use it in GitHub Desktop.
Save ashishtiwari1993/00b2a56ac8f5b39d3229d723e58815bc to your computer and use it in GitHub Desktop.
This code will make 100% CPU utilization and `forever()` function not going to share any single CPU time with `anotherGoroutine()`
package main
import (
"fmt"
)
func main() {
go anotherGoroutine()
forever()
}
func forever() {
for {
}
}
func anotherGoroutine() {
i := 0
for {
i++
fmt.Print(i)
fmt.Print("\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment