Tag: channel
-
Post Views: 19 problem background In Go language, when we read data from an unclosed channel, the read operation blocks if there is no data in the channel. The traditional practice is to traverse the channel until it is closed, but in actual development, we may not be able to determine when the channel should be turned off, or when…
-
Post Views: 23 In programming learning, judging prime numbers is a classic algorithm problem. When the amount of data is small, the traditional serial loop is enough to cope; but when the amount of data is expanded to hundreds of thousands or more, how to improve the computing efficiency has become the key. Based on the Go language, this paper…
-
Post Views: 36 In the concurrent programming of the Go language, the channel (channel) is the bridge connecting the goroutine. Many beginners often encounter “deadlock” errors when using unbuffered channels, or are confused about the blocking mechanism of the channel. This article will use a specific case to compare two different channel usage scenarios, and deeply analyze the blocking principle…
-
Post Views: 49 In the official tutorial of Go language, Web Crawler practice is a very classic concurrent programming case. It requires us to modify a basic recursive crawler so that it can crawl the URL in parallel, while ensuring that the same URL is not repeated. This article will take you to analyze the original code problem step by…
-
Post Views: 102 Preface In most programming languages, it is quite complex to check if two binary trees store the same sequence of values. It is usually necessary to write a recursive algorithm to traverse the two trees and then compare them by node. But in the Go language, we can use its powerful concurrent primitives and channel (channel) mechanisms…
-
Post Views: 66 In the previous Go concurrency review, I focused on the many drawbacks of ‘global variable lock synchronization’ through factorial cases, especially the core question of ‘there are still hidden dangers when adding locks and hibernation’ Question – Manually set the sleep time to accurately match the rhythm of the execution of the protocol. If the resource is…
-
Post Views: 45 In Go language concurrent programming, channel (pipe) is the core mechanism of communication between goroutines, which follows The design philosophy of communicating to share memory, rather than communicating through shared memory, fundamentally solves many hidden dangers of global variable lock synchronization. In the previous study, we understood the necessity of the channel through the factorial case. This…
-
Post Views: 94 In Go language concurrent programming, goroutine is the core of efficient concurrency, but the communication and synchronization between multiple goroutines is often a place for beginners to easily step on pits. This article will take ‘calculate the factorials of 1-200 and store them into Map’ as a case, and combine the problems encountered in the learning process,…
-
Post Views: 39 1. The copy API application is QQ and WX. After adjusting the corresponding configuration, the final application directory structure is as follows 2. Nginx-based single domain name configuration on Yii 2 advanced project template, refer to the website:https://www.shuijingwanwq.com/2018/08/16/2836/, the API application is cross-channel, the QQ application is Penguin, and the WX application is the WeChat public account,…