This is a created article in which the information may have evolved or changed.
There is a significant difference between buffer and unbuffered Golang channel.
I was naïve to think that there is a buffer and no buffer difference just unbuffered is the default buffer of 1 buffer
In fact, it's completely wrong, and there's a big difference between unbuffered and buffered channel.
That's one of the synchronizations that is a non-synchronous
What do you say? Like what
C1:=make (chan int) unbuffered
C2:=make (Chan int,1) has a cushion
C1<-1
Unbuffered not only to the C1 Channel 1 but always have to have other Ctrip <-C1 took over this parameter, then c1<-1 will continue, otherwise it has been blocked
The c2<-1 is not blocked because the buffer size is 1 (in fact the buffer size is 0) only when the second value is not taken away from the first one, it will only block.
Make a metaphor.
No buffer is a messenger to your door to send letters, you are not at home he does not go, you must take the letter, he will go.
No buffer guarantee to get your hands on the letter.
There is a buffer is a messenger to your home still to your home mailbox turned away, unless your mailbox is full he must wait for the mailbox empty.
There is a buffer guarantee to enter your home mailbox.
++++++++++++++++++++++++++++++++++++++
"I concluded that" the non-buffered channel is blocked until it can get data from Chan, and the buffered channel is blocking the code that executes the main thread as long as it can fetch one!