Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c04/c04_04 #40

Open
utterances-bot opened this issue May 26, 2022 · 5 comments
Open

c04/c04_04 #40

utterances-bot opened this issue May 26, 2022 · 5 comments

Comments

@utterances-bot
Copy link

4.4 学习 Go 协程:详解信道/通道 — Go编程时光 1.0.0 documentation

https://golang.iswbm.com/c04/c04_04.html

Copy link

只读,只写信道的demo,用的不是同一个双向信道吗?只是定义了不同的变量名字而已啊,那有什么意义呢,本质上用的还是双向信道

@iswbm
Copy link
Owner

iswbm commented Jun 11, 2022

只读,只写信道的demo,用的不是同一个双向信道吗?只是定义了不同的变量名字而已啊,那有什么意义呢,本质上用的还是双向信道

二者类型不一样。你可以试下效果

Copy link

当容量为0时,说明信道中不能存放数据,在发送数据时,必须要求立马有人接收,否则会报错。此时的信道称之为无缓冲信道。

这里应该是阻塞吧?

Copy link

当容量为0时,说明信道中不能存放数据,在发送数据时,必须要求立马有人接收,否则会报错。此时的信道称之为无缓冲信道。
请教一下,容量为0时,不能存放数据,那还怎么发数据呢?不能发数据,那又如何接收呢?

Copy link

测试了一下,channel为0,也是可以发送的,接收不到,就一直block,直到有数据进入了channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants