How to wait for data with ReentrantReadWriteLock?
问题 It is said, that ReentrantReadWriteLock is intended for one writer and multiple readers. Nevertheless, readers should wait until some data is present in the buffer. So, what to lock? I created concurrency objects like follows: private final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); protected final Lock readLock = rwl.readLock(); protected final Lock writeLock = rwl.writeLock(); protected final Condition hasData = writeLock.newCondition(); now in write method I do: writeLock