Skip to content
masterclass Buddy

Go · Class

sync.RWMutex

sync.RWMutex allows many readers or one writer to access shared data. A waiting writer prevents new readers from entering, which helps the writer eventually acquire the lock.

Last updated

Syntax

type RWMutex struct {}
func (rw *RWMutex) RLock()
func (rw *RWMutex) RUnlock()
func (rw *RWMutex) Lock()
func (rw *RWMutex) Unlock()
func (rw *RWMutex) TryRLock() bool
func (rw *RWMutex) TryLock() bool
func (rw *RWMutex) RLocker() Locker

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • RWMutex
  • RLock
  • TryRLock
  • RUnlock
  • Lock
  • TryLock
  • Unlock
  • RLocker

Source: The Go Programming Language: sync.RWMutex. Checked 2026-11-03.