一、介绍
sync.RWMutex为读写锁,源码地位在src/sync/rwmutex.go
咱们应用命令 go doc sync.RWMutex

type RWMutex struct {    w           Mutex  // held if there are pending writers    writerSem   uint32 // semaphore for writers to wait for completing readers    readerSem   uint32 // semaphore for readers to wait for completing writers    readerCount int32  // number of pending readers    readerWait  int32  // number of departing readers}func (rw *RWMutex) Lock()func (rw *RWMutex) RLock()func (rw *RWMutex) RLocker() Lockerfunc (rw *RWMutex) RUnlock()func (rw *RWMutex) Unlock()

咱们能够晓得 rwmutex.go 文件次要有 RWMutex构造体以及Lock()、RLock()、RLocker()、RUnlock()、Unlock() 5个办法组成。