public void writeLock() {
    lock.lock();
    try {
      while (!readCnt.isEmpty() || writeCnt > 0) {
        writeWait++;
        try {
          okToWrite.await();
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
        } finally {
          writeWait--;
        }
      }
      writeCnt++;
    } finally {
      lock.unlock();
    }
  }
Get a WriteLock and block and wait until the lock status is empty.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/lock/StampedWriterPreferredLock.java