mutex_test.go 214 B

12345678910111213141516171819
  1. package test
  2. import (
  3. "sync"
  4. "testing"
  5. )
  6. func TestMutex(t *testing.T) {
  7. m1 := sync.Mutex{}
  8. m1.Lock()
  9. defer m1.Unlock()
  10. m2 := sync.RWMutex{}
  11. m2.RLock()
  12. defer m2.RUnlock()
  13. m2.Lock()
  14. defer m2.Unlock()
  15. }