Created
February 12, 2015 22:29
-
-
Save Omie/52add99f6685dcb340a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"log" | |
"time" | |
) | |
var foo chan int | |
func fillFoo() { | |
for i := 0; i < 20; i++ { | |
//this will get blocked beyond 15 | |
foo <- i | |
log.Println("pushed", i) | |
} | |
close(foo) | |
} | |
func main() { | |
foo = make(chan int, 15) | |
go fillFoo() | |
for { | |
bar := <-foo | |
log.Println("popped", bar) | |
time.Sleep(2 * time.Second) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment