Skip to content

Instantly share code, notes, and snippets.

@jrusev jrusev/workers.go
Created Apr 8, 2017

Embed
What would you like to do?
package main
import "fmt"
import "time"
func f(in <-chan int, out chan<- int) {
for j := range in {
time.Sleep(time.Second)
out <- j * 2
}
}
func main() {
in := make(chan int, 100)
out := make(chan int, 100)
go f(in, out)
for j := 1; j <= 8; j++ {
in <- j
}
for a := 1; a <= 8; a++ {
fmt.Println(<-out)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.