您的位置:首页 > 编程语言 > Go语言

go的timer

2018-11-09 21:50 363 查看
版权声明:本文为博主原创文章,转载时请务必注明本文地址, 禁止用于任何商业用途, 否则会用法律维权。 https://blog.csdn.net/stpeace/article/details/83588490

       看程序:

[code]package main

import (
"fmt"
"time"
)

func main() {
time.AfterFunc(3 * time.Second, func() {fmt.Println("come here 1")})

timer := time.NewTimer(4 * time.Second)
<-timer.C
fmt.Println("come here 2")

<-time.After(5 * time.Second)
fmt.Printf("come here 3")

for {}
}

        一目了然。

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: