Skip to content

Instantly share code, notes, and snippets.

@doron2402
Created April 7, 2020 07:51
Show Gist options
  • Save doron2402/283a54e4be9a12342b40a0584a6b772f to your computer and use it in GitHub Desktop.
Save doron2402/283a54e4be9a12342b40a0584a6b772f to your computer and use it in GitHub Desktop.
Golang Concurrent - Go channels
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