mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
29 lines
535 B
Go
29 lines
535 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/gogf/gf/container/gtype"
|
|
"github.com/gogf/gf/os/gtimer"
|
|
)
|
|
|
|
func main() {
|
|
v := gtype.NewInt()
|
|
//w := gtimer.New(10, 10*time.Millisecond)
|
|
fmt.Println("start:", time.Now())
|
|
for i := 0; i < 1000000; i++ {
|
|
gtimer.AddTimes(time.Second, 2, func() {
|
|
v.Add(1)
|
|
})
|
|
}
|
|
fmt.Println("end :", time.Now())
|
|
time.Sleep(5000 * time.Millisecond)
|
|
fmt.Println(v.Val(), time.Now())
|
|
|
|
//gtimer.AddSingleton(time.Second, func() {
|
|
// fmt.Println(time.Now().String())
|
|
//})
|
|
//select { }
|
|
}
|