当前位置:网站首页>Go from introduction to actual combat - all tasks completed (notes)
Go from introduction to actual combat - all tasks completed (notes)
2022-06-27 21:37:00 【Accumulated Ytu】
func runTask(id int) string {
time.Sleep(10 * time.Millisecond)
return fmt.Sprintf("The result is from %d", id)
}
func FirstResponse() string {
numOfRunner := 10
ch := make(chan string, numOfRunner)
for i := 0; i < numOfRunner; i++ {
go func(i int) {
ret := runTask(i)
ch <- ret
}(i)
}
finalRet := ""
for i := 0; i < numOfRunner; i++ {
finalRet += <-ch + "\n"
}
return finalRet
}
边栏推荐
- 行业案例|从零售之王看银行数字化转型的运营之道
- Golang 使用正则来匹配出子字符串函数
- MySQL performance optimization index function, hidden, prefix, hash index usage (2)
- A set of system to reduce 10 times the traffic pressure in crowded areas
- 微服务之远程调用
- 2021全球独角兽榜发布:中国301家独角兽企业全名单来了!
- Experiment of love number lesson | phase V - emotion judgment of commodity review based on machine learning method
- 空指针异常
- squid代理服务器
- gomock mockgen : unknown embedded interface
猜你喜欢

创建对象时JVM内存结构

通过CE修改器修改大型网络游戏

一套系统,减轻人流集中地10倍的通行压力

Go从入门到实战——共享内存并发机制(笔记)

KDD 2022 | graph neural network generalization framework under the paradigm of "pre training, prompting and fine tuning"

How to do a good job of gateway high availability protection in the big promotion scenario

ICML2022 | 可扩展深度高斯马尔可夫随机场

本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献

BTC and eth recapture the lost land! Leading the market recovery? Encryption will enter the "ice age"!

白嫖红队goby&POC,叫你如何白嫖?
随机推荐
白嫖红队goby&POC,叫你如何白嫖?
Can Oracle's CTAs bring constraints and other attributes to the new table?
100 important knowledge points that SQL must master: using functions to process data
PCIE知识点-008:PCIE switch的结构
mysql使用笔记一
非常全面的DolphinScheduler(海豚调度)安装使用文档
SQL必需掌握的100个重要知识点:检索数据
释放开源数据库创新力量 | 【甘肃】openGauss Meetup圆满结束
gomock mockgen : unknown embedded interface
MySQL client tools are recommended. I can't imagine that it is best to use Juran
CORBA 架构体系指南(通用对象请求代理体系架构)
Go从入门到实战——依赖管理(笔记)
一套系统,减轻人流集中地10倍的通行压力
100 important knowledge points that SQL must master: retrieving data
Unleash the innovative power of open source database | [Gansu] opengauss meetup has come to a successful conclusion
ICML2022 | 可扩展深度高斯马尔可夫随机场
Let Ma Huateng down! Web3.0, hopeless
Full record of 2022 open source moment at Huawei partners and Developers Conference
White whoring red team goby & POC, how do you call white whoring?
Flexible IP network test tool -- x-launch