

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Mutexes in Go
incomplete
2: Why Is It Called a 'mutex'?
incomplete
3: Mutex Review
incomplete
4: RW Mutex
incomplete
5: Read/Write Mutex Review
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
The standard library also exposes a sync.RWMutex
In addition to these methods:
The sync.RWMutex also has these methods for concurrent reads:
The sync.RWMutex improves performance in read-intensive processes. Multiple goroutines can safely read from the map simultaneously, as many RLock() calls can occur at the same time. However, only one goroutine can hold a Lock(), and during this time, all RLock() operations are blocked.
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.
Run the new test suite. You'll notice that it hangs forever and you'll need to cancel it.
Update the val method to only lock the mutex for reading.