Created
April 8, 2017 13:31
-
-
Save jrusev/c624120fd4acd2698eefb32302d30a8d to your computer and use it in GitHub Desktop.
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" | |
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