为了更好地理解通道和goroutines的护理和喂养,我正在尝试构建一个Eratosthenes筛子,作为一组通过通道连接到管道中的goroutine。implements a Sieve of Eratosthenes// by goroutines
package mainouch <- next // Pass it to the next instan
close(out) fmt.Println("return statement is called ")}func mainfmt.Println(<-c) fmt.Println(<-c)完整代码:
我的理解是,一旦return被调用,该函数将被终止,并且该函数中的通道没有更多的生命但是out通道的内容被读取了很多次。在这种情况下,实际的执行流