Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the trap of Go unbuffered channel

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article shows you what the trap of Go unbuffered channel is, it is concise and easy to understand, and it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Define

Channel is one of the features of go, even the biggest feature is not too much, and it is very easy to use.

First define a channel of type int:

Ch2: = make (chan int) ch3: = make (chan int, 10)

Our main focus here is on unbuffered channels.

Scene

Take a look at this code:

Package mainimport ("sync"fmt") func main () {wg: = sync.WaitGroup {} ch2: = make (chan int) wg.Add (1) for I: = 0; I < 10; iTunes + {ch2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report