private long acquireReadLockStamp(boolean prior) {
    while ((prior ? writeCnt : writeCnt + writeWait) > 0) {
      readWait++;
      try {
        okToRead.await();
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
      } finally {
        readWait--;
      }
    }
    long allocateStamp = allocateUniqueStamp();
    readCnt.put(allocateStamp, 1);
    return allocateStamp;
  }
Acquires a read lock and block and wait if another thread holds a write lock or the write lock
waiting queue is not empty.

@param prior if the write lock waiting queue can be ignored
@return read lock stamp
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/lock/StampedWriterPreferredLock.java