Skip to content

Instantly share code, notes, and snippets.

@horzu
Created March 17, 2022 12:22
Show Gist options
  • Save horzu/52129fa78769b25421f8139286af2ad7 to your computer and use it in GitHub Desktop.
Save horzu/52129fa78769b25421f8139286af2ad7 to your computer and use it in GitHub Desktop.
Concurrency in Go: Go routines example - 1
package main
import (
"fmt"
"time"
)
func main() {
go counter("first")
go counter("second")
fmt.Scanln()
}
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