当前位置:网站首页>Go uses channel to control concurrency
Go uses channel to control concurrency
2022-06-25 05:58:00 【talen_ hx296】
package main
import (
"fmt"
"time"
)
// Maximum number of concurrent
const MAX_PROCESS = 10
var ch = make(chan string, MAX_PROCESS)
func main() {
for i := 0; i < MAX_PROCESS; i++ {
// start-up go runtine
go recive()
}
time.Sleep(1 * time.Hour)
close(ch)
}
func recive() {
for data := range ch {
DoSomething(data)
}
}
func DoSomething(data string) error {
defer dopanic()
fmt.Sprintf("doing %s...", data)
return nil
}
func dopanic() {
if r := recover(); r != nil {
fmt.Errorf("Error: %+v", r)
}
}边栏推荐
- Guava common collection tool classes
- Jz-066- motion range of robot
- CSDN cerebral palsy bug has wasted nearly two hours of hard work
- The simplest way to tell you is to hash and not hash
- Mirror image of binary tree
- PAT (Advanced Level) Practice 1025
- What is SAP sup - Sybase unwired platform
- C switch nested syntax
- Go microservice development toolkit
- Day13 (inner class, anonymous inner class, API common class)
猜你喜欢

Depth of binary tree
Linus' speech recordings, which were lost in 1994, were made public

No one reads the series. Source code analysis of copyonwritearraylist
Do you know what a three-tier architecture is?

Soft exam information system project manager_ Management Science (Operations Research) -- senior information system project manager of soft test 033
SAP ui5 Application Development Tutorial Part 30 - parameter transfer in the routing process of SAP ui5

"APEC industry +" biov Tech talks about the cross-border of Chinese biotechnology enterprises and "Pratt & Whitney Kangyu" | apec-hub public welfare
Some common errors and solutions of using SAP ui5 to consume OData services
MySQL transaction learning notes (I) first encounter

By inserting a section break, the word header, footer, and page number can start from any page
随机推荐
What is SAP sup - Sybase unwired platform
SAP ui5 tutorial for beginners part XXVI - detailed steps for using OData service with mock server trial version
Technology Review: what is the evolution route of container technology? What imagination space is there in the future?
Understanding of process, thread, task queue, event loop, macro task, micro task, execution stack and other concepts in JS
HashSet implementation class
About the definition of pointer variables (personal notes)
3.2.3 use tcpdump to observe TCP header information (supplement common knowledge of TCP protocol)
What changes have taken place in the project file after SAP ui5 tools ran the Fiori add deploy config command
[kicad image] download and installation
Day19 (variable parameter, enhanced for loop traversal, generic wildcard <? >, TreeSet, linkedhashset, nested traversal of sets, set set, static import,)
Day21 performance test process
1.5.3 use tcpdump to observe ARP communication process
SAP ui5 date type sap ui. model. type. Analysis of date parsing format
ArcGIS Engine + Visual Studio installation tutorial
Timed thread pool
Mongodb delete data
Introduction to the main features of kyma when the cloud native application runs
Folding mobile phones are expected to explode, or help Samsung compete with apple and Chinese mobile phones
The locally developed SAP ui5 application is deployed to the ABAP server to perform error analysis
Semantic segmentation fcns in the wild: pixel level adaptive and constraint based adaptation