Skip to content

Instantly share code, notes, and snippets.

@ceoro9
Created May 10, 2019 12:04
Show Gist options
  • Save ceoro9/49c518edfe79fd4239c56131dddff7af to your computer and use it in GitHub Desktop.
Save ceoro9/49c518edfe79fd4239c56131dddff7af to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
var get_value chan int
func send_value(x int) {
time.Sleep(int64(x) * 1E8)
get_value <- x
}
func main() {
values := []int{3, 1, 9, 7, 2, 6, 4, 8, 5, 10}
get_value = make(chan int)
for _, x := range values {
go send_value(x)
}
for range values {
fmt.Println(<- get_value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment