Created
December 4, 2015 13:47
-
-
Save perillo/c32f01a4d2f0bede4b82 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" | |
"time" | |
) | |
func producer(ch chan<- int) { | |
ch <- 0 | |
} | |
func producer_bad(ch chan<- int) { | |
consumer(ch) | |
} | |
func consumer(ch <-chan int) { | |
fmt.Println("consumed %d", <-ch) | |
} | |
func main() { | |
ch := make(chan int) | |
go producer(ch) | |
go producer_bad(ch) | |
time.Sleep(1 * time.Second) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment