Created
March 17, 2022 12:16
-
-
Save horzu/f82f46a1168254790cbfd4d35a165576 to your computer and use it in GitHub Desktop.
Concurrency in Go: Go routines example - 1
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" | |
"time" | |
) | |
func main() { | |
go counter("first") | |
go counter("second") | |
time.Sleep(time.Second * 2) | |
} | |
func counter(rank string) { | |
for i := 1; ; i++ { | |
fmt.Println(i, rank) | |
time.Sleep(time.Second * 1) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment