Created
February 28, 2020 13:58
-
-
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()`
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" | |
) | |
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