ReentrantReadWriteLock: what's the difference between ReadLock and WriteLock?

前端 未结 5 626
庸人自扰
庸人自扰 2020-11-30 20:33

What I know is:

  • ReadLock and WriteLock affect each other somehow
  • WriteLock is just like synchronized
  • ReadLock
5条回答
  •  失恋的感觉
    2020-11-30 21:16

    When a thread acquires a WriteLock, no other thread can acquire the ReadLock nor the WriteLock of the same instance of ReentrantReadWriteLock, unless that thread releases the lock. However, multiple threads can acquire the ReadLock at the same time.

提交回复
热议问题