public void releaseIndexWriteLockForRemove() {
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (isDebugEnabled) {
      logger.debug("Releasing write lock on Index {}", getName());
    }
    removeIndexLock.writeLock().unlock();
    if (isDebugEnabled) {
      logger.debug("Released write lock on Index {}", getName());
    }
  }
This makes current thread wait until all query threads are done using it.
geode-core/src/main/java/org/apache/geode/cache/query/internal/index/AbstractIndex.java