private void work() {
      boolean working = true;
      while (working) {
        try {
          MonitorTask latestTask = null;
          synchronized (this) {
            working = alive;
            if (working) {
              waiting = true;
            }
          }
          if (working) {
            try {
              latestTask = task.take(); // blocking
            } finally {
              synchronized (this) {
                waiting = false;
                working = alive;
              }
            }
          }
          if (working && latestTask != null) {
            for (StatisticsMonitor monitor : monitors) {
              try {
                monitor.monitor(latestTask.getSampleTimeMillis(),
                    latestTask.getResourceInstances());
              } catch (VirtualMachineError e) {
                SystemFailure.initiateFailure(e);
                throw e;
              } catch (Error e) {
                SystemFailure.checkFailure();
                logger.warn(LogMarker.STATISTICS_MARKER, "StatisticsMonitor {} threw {}", monitor,
                    e.getClass().getSimpleName(), e);
              } catch (RuntimeException e) {
                logger.warn(LogMarker.STATISTICS_MARKER, "StatisticsMonitor {} threw {}", monitor,
                    e.getClass().getSimpleName(), e);
              }
            }
          }
        } catch (InterruptedException e) {
          synchronized (this) {
            working = false;
          }
        }
      }
    }
Used to hand-off from producer to consumer
geode-core/src/main/java/org/apache/geode/internal/statistics/StatMonitorHandler.java