package main
import (
"fmt"
"time"
)
//01 停止定时器
func main2(){
timer:=time.NewTimer(time.Second*2)
go func(){
<-timer.C
fmt.Println("时间到")
}()
timer.Stop()
for{}
}
//01 重置定时器
func main(){
timer:=time.NewTimer(time.Second*5)
timer.Reset(1*time.Second)
<-timer.C
fmt.Println("时间到")
}
5.20 go停止和重置定时器(time)
猜你喜欢
转载自blog.csdn.net/h4241778/article/details/105476432
今日推荐
周排行