2 ms·
the compiler will definitly inline this part: if size == 1 { c <- num return }
by merb 11y ago
the compiler will definitly inline this part:
if size == 1 {
c <- num
return
}
- sirclueless 11y agoNo it will not, and can not. "c <- num" is a blocking statement. Since c is an unbuffered channel, execution cannot proceed past the statement until a reader consumes a value. The reader in this case creates 10 goroutines executing "c <- num" and only then starts consuming values. If the statements you wrote were inlined execution would immediately halt in a deadlock.