go - Why is this program producing output -


I'm new to google from GO here is a program in Buffered Channels:

  package main import "fmt" import "time" func main () {c: = make (chan int, 2) c & lt; - 1 fmt println (& lt; -c) time.Sleep (1000 * time.Millisecond) c & lt; - 2 fmt.Println (& lt; -c)}   

produces the product. But according to this it says:

A buffer sends the channel block when the buffer is full . The block is received when buffer is empty.

As it says when only the full program is completed in the c first statement?

Your channel has a buffer size, you are pulling an int after inserting an int. Then you sleep and repeat the process. The channel will not block unless you try to insert a third intrate without dragging any intersection. The first two bricks will be buffer.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -