github.com/suiyunonghen/DxCommonLib@v0.5.3/sync/deadlock_test.go (about) 1 package sync 2 3 import ( 4 "fmt" 5 "github.com/suiyunonghen/DxCommonLib" 6 "os" 7 "strconv" 8 "testing" 9 "time" 10 ) 11 12 func doTest() { 13 StartDeadCheck(func(deadLocks []byte){ 14 fmt.Println(DxCommonLib.FastByte2String(deadLocks)) 15 },time.Second * 10,time.Second * 30,func(panicMsg bool,format string, data ...interface{}) { 16 fmt.Fprintf(os.Stdout,format,data...) 17 }) 18 var mu RWMutexEx 19 mu.LockWithMsg("测试信息:root") 20 for i := 0;i<3;i++{ 21 go func(v int) { 22 mu.LockWithMsg("测试信息:"+strconv.Itoa(v)) 23 time.Sleep(time.Second * 15) 24 mu.Unlock() 25 }(i) 26 } 27 time.Sleep(time.Second * 40) 28 mu.Unlock() 29 } 30 31 func TestRWMutexEx_Lock(t *testing.T) { 32 doTest() 33 }