Created
December 21, 2016 21:12
-
-
Save mertkahyaoglu/34fd8edc681481697864d59603118198 to your computer and use it in GitHub Desktop.
Go routine example
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 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