class MaxLongGauge {

  public void recordMax(long currentValue) {
    boolean done = false;
    while (!done) {
      long maxValue = max.get();
      if (currentValue <= maxValue) {
        done = true;
      } else {
        done = max.compareAndSet(maxValue, currentValue);
        if (done) {
          stats.incLong(statId, currentValue - maxValue);
        }
      }
    }
  }

  public  MaxLongGauge(int statId, Statistics stats);

}