code: @Override
      public void run() {
          while(_enabled) {
              if(_newCycle.compareAndSet(true, false)) {
                  // One and only one compactor is at work.
                  _lock.lock();
                  
                  try {
                      reset();
                      _state = State.INIT;
                      _log.info("cycle init");
                      
                      // Flush segment index buffers
                      flushSegmentIndexBuffers();
                      
                      // Free compacted segments
                      freeCompactedSegments();
                      
                      // Inspect the array
                      if(!inspect()) continue;
                      
                      // Compact the array
                      if(!compact()) continue;
                  } catch(Exception e) {
                      _log.error("compaction failure", e);
                  } finally {
                      reset();
                      _state = State.DONE;
                      _log.info("cycle done");
                      _lock.unlock();
                  }
              } else {
                  try {
                      Thread.sleep(100);
                  } catch (InterruptedException e) {
                      _log.warn(e.getMessage());
                  }
              }
          }
      }
docs: Compacting Segments.