标签:style blog color ar sp div on log bs
Channels can be buffered. Provide the buffer length as the second argument to make
to initialize a buffered channel:
ch := make(chan int, 100)
Sends to a buffered channel block only when the buffer is full. Receives block when the buffer is empty.
Modify the example to overfill the buffer and see what happens.
package main import "fmt" func main() { c := make(chan int, 2) c <- 1 fmt.Println(<-c) fmt.Println(<-c) }
A Tour of Go Buffered Channels
标签:style blog color ar sp div on log bs
原文地址:http://www.cnblogs.com/ghgyj/p/4058315.html