Standard library / sync

sync.RWMutex.RLocker()

Return a Locker whose Lock and Unlock methods acquire and release a read lock. Expected stdout: 'reader\n'.

Formal Syntax & Structure

go syntaxgo
func (rw *RWMutex) RLocker() Locker

Return Value

Locker

Locker adapter for read access.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync")
func main() { var m sync.RWMutex; l := m.RLocker(); l.Lock(); fmt.Println("reader"); l.Unlock() }
Go Reference