gf/geg/os/gtimer/ticker1.go
2019-04-03 00:03:46 +08:00

22 lines
275 B
Go

package main
import (
"fmt"
"time"
)
func main() {
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())
}