@Override
    protected List<Segment> getSnapshotSegments() {

      List<Segment> result = super.getSnapshotSegments();

      if (Thread.currentThread().getName().equals(GET_SCANNER_THREAD_NAME)) {
        int currentCount = getSnapshotSegmentsCounter.incrementAndGet();
        if (currentCount == 1) {
          if (this.shouldWait) {
            try {
              /**
               * Notify flush thread {@link DefaultMemStore#getSnapshotSegments} completed,
               * {@link DefaultMemStore#doClearSnapShot} could continue.
               */
              preClearSnapShotCyclicBarrier.await();
              /**
               * Wait for {@link DefaultMemStore#doClearSnapShot} completed.
               */
              postClearSnapShotCyclicBarrier.await();

            } catch (Throwable e) {
              throw new RuntimeException(e);
            }
          }
        }
      }
      return result;
    }
Used by flush thread notifies getScanner thread {@link DefaultMemStore#doClearSnapShot}
completed, {@link DefaultMemStore#getScanners} could continue.
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java