NOTE
6.19 ReentrantReadWriteLock
Exclusive locks prevent concurrent readers, while read-write locks allow them. These notes introduce ReentrantReadWriteLock through that need.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is ReentrantReadWriteLock?
ReentrantLock ensures that only one thread at a time can read or write data in the critical section. This means that even if two reader threads are reading data at the same time, ReentrantLock allows only one of them through. What we want, however, is for reads to execute concurrently, while any write causes the other threads to wait. The behavior is shown below:
| Can proceed at the same time | Read | Write |
|---|---|---|
| Read | √ | × |
| Write | × | × |
That is why ReentrantReadWriteLock exists.
2. ReentrantReadWriteLock Categories
3. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub