gf/.example/os/gtimer/ticker2.go

22 lines
275 B
Go
Raw Normal View History

2019-01-09 12:54:37 +08:00
package main
import (
2019-04-03 00:03:46 +08:00
"fmt"
"time"
2019-01-09 12:54:37 +08:00
)
func main() {
2019-04-03 00:03:46 +08:00
fmt.Println("start:", time.Now())
index := 0
ticker := time.NewTicker(10 * time.Millisecond)
for {
<-ticker.C
index++
fmt.Println(index)
if index == 100 {
break
}
}
fmt.Println(" end:", time.Now())
2019-01-09 12:54:37 +08:00
}