gokins/engine/timermgr_test.go
2021-07-22 10:53:38 +08:00

38 lines
441 B
Go

package engine
import (
"fmt"
"sync"
"testing"
"time"
)
func TestTimer(t *testing.T) {
tm := time.NewTimer(time.Second * 5)
select {
case <-tm.C:
fmt.Println(<-tm.C)
default:
fmt.Println("default")
}
fmt.Println(tm)
}
func TestSync(t *testing.T) {
lk := sync.RWMutex{}
go func() {
for {
lk.Lock()
fmt.Println(1)
lk.Unlock()
}
}()
go func() {
for {
lk.Lock()
fmt.Println(2)
lk.Unlock()
}
}()
}