Created
April 7, 2020 07:51
-
-
Save doron2402/283a54e4be9a12342b40a0584a6b772f to your computer and use it in GitHub Desktop.
Golang Concurrent - Go channels
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 say(str string) { | |
time.Sleep(1 * time.Millisecond) | |
for i := 0; i < 10; i++ { | |
fmt.Printf("%d) %v\n", i, str) | |
} | |
} | |
func main() { | |
go say("Hello") | |
go say("World") | |
go say("Bye") | |
time.Sleep(100 * time.Millisecond) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment