当前位置:网站首页>Go从入门到实战——所有任务完成(笔记)
Go从入门到实战——所有任务完成(笔记)
2022-06-27 19:22:00 【积淀 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
}
边栏推荐
- Full record of 2022 open source moment at Huawei partners and Developers Conference
- BTC and eth recapture the lost land! Leading the market recovery? Encryption will enter the "ice age"!
- VMware vSphere esxi 7.0 installation tutorial
- Flexible IP network test tool -- x-launch
- SQL server for circular usage
- Zhongang Mining: the largest application field of new energy or fluorite
- 1030 Travel Plan
- Industry case | see the operation of bank digital transformation from the king of retail
- Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer
- Day8 ---- 云资讯项目介绍与创建
猜你喜欢

MySQL usage notes 1

分享|智慧环保-生态文明信息化解决方案(附PDF)

华为伙伴暨开发者大会2022开源时刻全纪录

大促场景下,如何做好网关高可用防护

DO280OpenShift访问控制--security policy和章节实验

Yu Wenwen, Hu Xia and other stars take you to play with the party. Pipi app ignites your summer

Modify large online games through CE modifier

Codeforces Round #723 (Div. 2)

Save method of JPA stepping pit series

SQL server for circular usage
随机推荐
Safe and efficient, non-contact "hand brushing" identification helps epidemic prevention and control
Oracle的CTAS能不能将约束等属性带到新表?
Love math experiment | phase VI - Financial anti fraud case study
1029 Median
系统自带的karsonzhang/fastadmin-addons报错
关于企业数字化的展望(38/100)
SQL必需掌握的100个重要知识点:用通配符进行过滤
SQL server for circular usage
Codeforces Round #717 (Div. 2)
OpenSSL 编程 一:基本概念
Love math experiment | phase 9 - intelligent health diagnosis using machine learning method
一套系统,减轻人流集中地10倍的通行压力
Icml2022 | scalable depth Gaussian Markov random field
小王的面试训练任务
让马化腾失望了!Web3.0,毫无希望
MySQL usage notes 1
Is it safe to open an account and buy stocks? Who knows
Flask----应用案例
Flutter隐藏AppBar的返回按钮
Flood fighting and disaster relief, overcoming difficulties, and City United premium products rushed to the aid of Yingde to donate loving materials