Answer the question
In order to leave comments, you need to log in
Question about channels and blocking?
I'm trying to understand how Go works. and something does not reach
Why in this case the program is blocked.
func main() {
intCh := make(chan int)
intCh <- 10 // функция main блокируется
fmt.Println(<-intCh)
}
func main() {
intCh := make(chan int,100)
intCh <- 10 // функция main неблокируется
fmt.Println(<-intCh)
}
Answer the question
In order to leave comments, you need to log in
A channel in Go is a queue of declared capacity (implemented by a ring buffer). If you do not take it from the queue, it clogs and blocks.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question