package
0.0.0-20230817172732-9976b92f604f
Repository: https://github.com/bootdotdev/fcc-learn-golang-assets.git
Documentation: pkg.go.dev

# README

RW Mutex

The standard library also exposes a sync.RWMutex

In addition to these methods:

The sync.RWMutex also has these methods:

The sync.RWMutex can help with performance if we have a read-intensive process. Many goroutines can safely read from the map at the same time (multiple Rlock() calls can happen simultaneously). However, only one goroutine can hold a Lock() and all RLock()'s will also be excluded.

Assignment

Let's update our same code from the last assignment, but this time we can speed it up by allowing readers to read from the map concurrently.

Update the val method to only lock the mutex for reading. Notice that if you run the code with a write lock it will block forever.