Merge pull request #335 from Instrye/patch-1

更改:练习 14.4中 睡眠时间为2e9
This commit is contained in:
无闻
2017-03-27 22:37:12 -04:00
committed by GitHub

View File

@@ -84,7 +84,7 @@ func sendData(ch chan string) {
func getData(ch chan string) {
var input string
// time.Sleep(1e9)
// time.Sleep(2e9)
for {
input = <-ch
fmt.Printf("%s ", input)
@@ -118,7 +118,7 @@ Washington Tripoli London Beijing Tokio
注意不要使用打印状态来表明通道的发送和接收顺序由于打印状态和通道实际发生读写的时间延迟会导致和真实发生的顺序不同
练习 14.4解释一下为什么如果在函数 `getData()` 的一开始插入 `time.Sleep(1e9)`不会出现错误但也没有输出呢
练习 14.4解释一下为什么如果在函数 `getData()` 的一开始插入 `time.Sleep(2e9)`不会出现错误但也没有输出呢
## 14.2.3 通道阻塞