首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
The Go Programming Language
›
http://golang.org/
›
Go Playground
Go Projects
›
Revel Web Framework
广告
V2EX
›
Go 编程语言
unbuffered channel 和只有一个元素的 buffered channel 有啥区别
ponymaggie
·
2022-06-21 10:47:13 +08:00
· 1129 次点击
这是一个创建于 739 天前的主题,其中的信息可能已经有所发展或是发生改变。
比如:
sema = make(chan struct{}, 1)
和 sema = make(chan struct{})
都是只能放一个元素,读取之前再放的话就会等待
struct
sema
chan
channel
2 条回复
•
2022-06-21 15:59:05 +08:00
1
iBugOne
2022-06-21 10:50:42 +08:00
1
unbuffered channel 第一个元素都放不进去吧,会卡到有人读才行
https://go.dev/play/p/UJGaZDcKzDW
2
qianxi0410
2022-06-21 15:59:05 +08:00
unbuffered channel 会卡发送者,buffer channel 不卡
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
2462 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 24ms ·
UTC 13:38
·
PVG 21:38
·
LAX 06:38
·
JFK 09:38
Developed with
CodeLauncher
♥ Do have faith in what you're doing.