当前位置:网站首页>Golang worker pool
Golang worker pool
2022-07-27 18:10:00 【gitxuzan_】
package main
import (
"fmt"
"github.com/gammazero/workerpool"
"time"
)
func main() {
wp := workerpool.New(2)
requests := []string{
"alpha", "beta", "gamma", "delta", "epsilon"}
for _, r := range requests {
wp.Submit(
func(r string ) func(){
return func() {
fmt.Println("Handling request:", r)
time.Sleep(2*time.Second)
}
}(r),
)
}
wp.StopWait()
}
边栏推荐
- 注释中的{@code}、{@Link} 与<p>等标签
- 最新大厂高级面试题 必备
- The Ministry of industry and information technology re governs data security, and Netease Yidun "privacy compliance" keeps the bottom line of enterprise operation
- Error launching IDEA
- Hutool digital computing
- 查找表中多余重复记录并删除保留最小一个
- In the first week of June, risk control of e-shield business paid attention to 15 institutions such as New Oriental XRS, which were fined
- How can we carry out NLP cross language knowledge transfer?
- golang 自定义once,当出现error第二次重新设置
- Bubble sorting in JS
猜你喜欢

Big gap? Requirements and conditions for candidates with different academic qualifications to take the postgraduate entrance examination

canvas根据坐标点绘制图形

Numpy array matrix operation

Fast parsing combined with Huatu document encryption software

类的六大关系——依赖和关联的区别

Learn from things | Yidun mobile terminal isomorphism practice, improve the official website interaction experience in a few steps

How can we carry out NLP cross language knowledge transfer?

Class not found: “com.parkManagement.dao.DaoTest 测试找不到测试类

WPF makes login interface

面试常见问题一二
随机推荐
年终总结模板
知物由学 | 易盾自研文本实时聚类技术,一网打尽社交网络中的同类有害内容
[user article] examples of P4 consolidation practice guide disassemble resolve
最新大厂高级面试题 必备
2022 safety officer-a certificate examination questions and online simulation examination
Hutool array tool
TCP connection status identification (syn, fin, ACK, PSH, RST, urg)
Prevent SQL injection
How can we carry out NLP cross language knowledge transfer?
[introduction to database system (Wang Shan)] Chapter 4 - Database Security
Original direct selling MOS tube knl42150 2.8a/1500v applicable photovoltaic inverter can provide samples
Understand JVM language
PostgreSQL 14 支持winserver2022吗?
知物由学 | 关联图分析在反作弊业务中的应用
Backup table recovery table
Convolutional neural network -- Translation of yolov2 (yolo9000) papers
Notes on standardized management of "ancestral warehouse" of meituan meal
About the problem of abnormal C printing
机器学习之评价指标(一)——回归评价指标
What's the use of games| Game application value research case collection