Standard library / sync

sync.RWMutex

A reader/writer lock permits multiple readers or one writer. Do not copy after use; upgrading a read lock is unsupported. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
type RWMutex struct {}

Working Example

Example Snippetgo
package main
import (  "fmt"  "sync")
func main() {  var m sync.RWMutex  m.Lock()  n := 3  m.Unlock()  m.RLock()  fmt.Println(n)  m.RUnlock()}
Go Reference