Gorutas have no channels or values sent to them. Thus, the execution status of the goroutine that sent / sends values in the channel does not affect the ability of other goroutines to send or receive values on this channel, unless the channel buffer is full, in which case all sendings will be blocked until the appropriate reception occurs, or the buffer is empty, in which case all received will be blocked until the corresponding sending appears.
Since goroutines use collaborative scheduling (they must be inferior to the scheduler either through a channel operation, or syscall, or by explicitly calling runtime.Gosched() ), it is not possible for the goroutine to be interrupted at the “worst possible time”. Gorutin can never go out, and in this case he can endlessly bind a thread. If you have only one thread of execution, then your other goroutines will never be scheduled. It is possible, but statistically unlikely, that goroutine was never planned. However, if all but one goroutines are blocked during sending or receiving, then the remaining goroutine should be planned.
You can come to a standstill. If I have two goroutines running:
func Goroutine(ch1, ch2 chan int) { i := <-ch1 ch2 <- i } ... ch1, ch2 := make(chan int), make(chan int) go Goroutine(ch1, ch2) go Goroutine(ch2, ch1)
Then, as should be obvious, both goroutines are waiting for the other to send a value that will never happen.
SteveMcQwark
source share