当前位置:网站首页>Code examples of golang goroutine, channel and time
Code examples of golang goroutine, channel and time
2022-06-23 16:23:00 【Learn programming notes】
golang goroutine、channel、time Code example
package main
import (
"time"
"fmt"
)
func timenow(ch chan string) {
tn := time.Now().Format("2006 year 01 month 02 Japan 15 spot 04 branch 05 second .0000000 The time zone -0700")
ch <-tn
}
func main (){
ch:=make(chan string)
for i:=0;i<10;i++ {
go timenow(ch)
fmt.Println(<-ch)
time.Sleep(500*time.Millisecond)
}
}
/* ################ Running results ################## PS D:\golang\github\golang_project\go Implementation cases demo\goroutine、channel、time Example > go run .\goroutine+channel+time.go 2020 year 08 month 10 Japan 10 spot 19 branch 27 second .2609770 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 27 second .7786030 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 28 second .2792588 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 28 second .7794479 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 29 second .2805396 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 29 second .7809675 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 30 second .2814328 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 30 second .7820869 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 31 second .2829391 The time zone +0800 2020 year 08 month 10 Japan 10 spot 19 branch 31 second .7834190 The time zone +0800 */
边栏推荐
- 【OpenHarmony】usb gadget 配置hdc功能cfg文件解读
- HBuilderX-Light 主题能不能加个批注功能?
- golang数据类型图
- How did Tencent's technology bulls complete the overall cloud launch?
- Introduction to asynccontext
- Server deployment and instructions
- Block, non block, multiplexing, synchronous, asynchronous, bio, NiO, AIO
- npm install 问题解决(nvm安装与使用)
- Block, non block, multiplexing, synchronous, asynchronous, bio, NiO, AIO
- R语言使用colorblinr包模拟色盲视觉、将已有的ggplot2可视化结果图像使用edit_colors函数编辑转化为色盲视觉友好的可视化结果、并自定设置色盲形式、色盲严重级别
猜你喜欢

【TcaplusDB知识库】Tmonitor系统升级介绍

进阶开发- 泛型入门基础类测试

Quartz

【TcaplusDB知识库】Tmonitor后台一键安装介绍(一)

万字攻略,详解腾讯面试(T1-T9)核心技术点,面试题整理

【历史上的今天】6 月 23 日:图灵诞生日;互联网奠基人出生;Reddit 上线
NLP 论文领读|改善意图识别的语义表示:有监督预训练中的各向同性正则化方法

Advanced development - generic entry basic class test

leetcode:30. 串联所有单词的子串【Counter匹配 + 剪枝】

【TcaplusDB知识库】Tmonitor单机安装指引介绍(二)
随机推荐
批量注册组件
If no code is moved, the project access speed drops significantly the next day. Case analysis
【TcaplusDB知识库】Tmonitor单机安装指引介绍(二)
Innovation strength is recognized again! Tencent security MSS was the pioneer of cloud native security guard in 2022
golang gob实现网络数据的传输
Object
uniapp对接腾讯即时通讯TIM 发图片消息问题
Batch registration component
Now I want to buy stocks. How do I open an account? Is it safe to open a mobile account?
How NPM contracts and deletes packages
How is it cheaper to open a stock account? Is it safe to open an account online now?
ADB key name, key code number and key description comparison table
HBuilderX-Light 主题能不能加个批注功能?
PageHelper在面对复杂service数据处理下的分页问题
Tableau comparatif du nom de la clé ADB, du numéro du Code de la clé et de la description de la clé
【解决】npm WARN config global `--global`, `--local` are deprecated. Use `--location=global`
Spin lock using CAS
NLP 论文领读|改善意图识别的语义表示:有监督预训练中的各向同性正则化方法
Solution: in the verification phase, the first batch does not report errors, and the second batch reports CUDA exceeded errors
Servlet 3.0的AsyncListener接口