Skip to content

Instantly share code, notes, and snippets.

@mertkahyaoglu
Created December 21, 2016 21:12
Show Gist options
  • Save mertkahyaoglu/34fd8edc681481697864d59603118198 to your computer and use it in GitHub Desktop.
Save mertkahyaoglu/34fd8edc681481697864d59603118198 to your computer and use it in GitHub Desktop.
Go routine example
package main
import (
"fmt"
"time"
)
func count(id int) {
for i := 0; i < 10; i++ {
fmt.Println(id, ":", i)
time.Sleep(time.Millisecond * 1000)
}
}
func main() {
for i := 0; i < 10; i++ {
go count(i)
}
time.Sleep(time.Millisecond * 11000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment