protected StatSampler(StatCollector s) {
   this.id = s.getId() + "_MAX";
   this.stat = s;
   final Runnable runnable =
       new Runnable() {
         public void run() {
           if (!hasStarted.get()) {
             return;
           }
           try {
             final long newVal = stat.getVal();
             synchronized (value) {
               final long val = value.get();
               if (Math.abs(newVal) > Math.abs(val)) {
                 value.set(newVal);
               }
               exceptionRef.set(null);
             }
           } catch (StatUnreachableException e) {
             exceptionRef.set(e);
           } catch (Throwable t) {
             log.error(t, t);
           }
         }
       };
   scheduleAtFixedRate(runnable, 1000);
 }
 public void register(final StatCollector stat) {
   // can't register any stats after the collector has been initially
   // started due to the need for consistent ordering in the csv output
   // file
   if (hasStarted.get()) {
     log.warn(
         stat.getId()
             + " attempted to register in stat collector although it has "
             + " already been started, not allowing");
     return;
   }
   if (statKeys.containsKey(stat.getId())) {
     log.warn(
         stat.getId()
             + " attempted to register in stat collector although it has "
             + " already been registered, not allowing");
     return;
   }
   statKeys.put(stat.getId(), stat);
 }