NOTE

6.19 ReentrantReadWriteLock

1. What ReentrantReadWriteLock is. 2. ReentrantReadWriteLock categories. 3. References.

JavaCreated Updated 1 min readhistorical

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

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub