golang time
程序员文章站
2022-06-25 19:20:46
...
package main
import (
"fmt"
"time"
)
func main() {
futureTimer := time.NewTicker(5 * time.Second)
defer futureTimer.Stop()
for {
select {
case <-futureTimer.C:
fmt.Println("Hello!")
}
}
}
运行结果: 每个5秒打印一次
Hello!
Hello!
Hello!
......
推荐阅读