![ read chan by for range in main-thread.png](https://static.studygolang.com/190217/615aabb98cdf18b6e24423e6c25969a5.png)
* <a href="/user/didadi" title="@didadi">@didadi</a> 正解
* for-range的loop只有在channel被关闭后才会退出。所以会block你的main goroutine,造成Dead Lock。
* 如果你使用如下code,就不会Dead Lock(即使没有关闭channel):
```
package main
import "fmt"
func main() {
ch := make(chan int, 1)
for i := 0; i < 10; i++ {
go Send(ch, i)
}
for i := 0; i < 10; i++ {
fmt.Printf("i: %v\n", <-ch)
}
}
func Send(ch chan int, number int) {
ch <- number
}
```
* [for range loop on a Channel will Never Exit until it is Closed](https://github.com/northbright/Notes/blob/master/Golang/concurrency/for-range-loop-on-a-channel-will-never-exit-until-it-is-closed.md)
#11
更多评论
@waini1110</a>
#### 首先感谢回答,另外:
##### 对于读取来说应该是发现channel有数据就拿 ,没有数据就阻塞
##### 对于发送来说向channel中存,存完阻塞,等待channel数据被取走后再存
##### 现在我在main中不断读取channel, 假设channel不存在数据,他应该只是阻塞状态,为什么会提示 all goroutines are asleep - deadlock
#2