当前位置:网站首页>Go channel simple notes
Go channel simple notes
2022-07-25 17:39:00 【kankan231】
go The channel of is used for goroutine Communication and data synchronization between , yes go One of the more important types in
nil passageway :
not used make For initialization chan The default value is nil, Read / write in nil The channel will permanently block the current process , close nil Channel meeting panic
No buffer channel :
Use make If the number of channels is not specified when initializing them, they are unbuffered channels , Both reading and writing must be operated at the same time to prevent blocking , When there is reading but no writing , Read will block , When there is writing but no reading , Writing will block
There are buffer channels :
Use make When initializing channels, the specified number is buffered channels , When the buffer is not full , Writing will not block , Otherwise blocking ; When there is data in the buffer , Reading will not block , Otherwise blocking
Closed channel :
Use close(ch) After closing the channel , Reading this channel will immediately return the zero value of this channel type , Writing to a closed channel will panic
When using channels , Attention should be paid to the problem that the cooperation process cannot exit due to the blockage of the operation channel , This leads to memory leaks
边栏推荐
- 我们被一个 kong 的性能 bug 折腾了一个通宵
- HCIP第一天实验
- 【VSCODE】支持argparser/接受命令行参数
- I2C communication - sequence diagram
- Installation steps and usage of NVM under windows10 system
- Summary of 80 domestic database operation documents (including tidb, Damon, opengauss, etc.)
- 关于flickr的数据集笔记
- Interface automation test postman+newman+jenkins
- [Hardware Engineer] Why do DC-DC isolated switching power modules use transformers?
- The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...
猜你喜欢

Tkinter module advanced operations (I) -- transparent buttons, transparent text boxes, custom buttons and custom text boxes

WPF 实现用户头像选择器

对灰度图像的三维函数显示

Food safety | eight questions and eight answers take you to know crayfish again! This is the right way to eat!

精彩记录

Wu Enda logistic regression 2

Technical difficulties and applications of large humanoid robots

Three dimensional function display of gray image

Dating activity records

Excel表格 / WPS表格中怎么在下拉滚动时让第一行标题固定住?
随机推荐
04. Find the median of two positive arrays
EDI docking commercehub orderstream
[cadence Allegro PCB design] permanently modify the shortcut key (customized) ~ it is valid for personal test~
计算日期或日期格式化
交叉验证(cv)学习笔记
Is it safe to open a futures account online? How to apply for a low handling fee?
Dating activity records
Cross validation (CV) learning notes
8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇
The gas is exhausted! After 23 years of operation, the former "largest e-commerce website in China" has become yellow...
生成扩散模型漫谈:DDPM = 贝叶斯 + 去噪
HCIP第一天实验
I2C communication - sequence diagram
约瑟夫环问题
After consulting about how to deal with DDL in Flink SQL client, how to add fields and jobs to the mapping table in Fink SQL?
STM32 PAJ7620U2手势识别模块(IIC通信)程序源码详解
Step by step introduction of sqlsugar based development framework (13) -- package the upload component based on elementplus, which is convenient for the project
[solution] the Microsoft edge browser has the problem of "unable to access this page"
接口自动化测试Postman+Newman+Jenkins
03. Longest substring without repeated characters