@Test
  public void testStatMonitorNotifierWakesUpForWork() throws Exception {
    StatMonitorHandler handler = new StatMonitorHandler();
    TestStatisticsMonitor monitor = new TestStatisticsMonitor();
    handler.addMonitor(monitor);

    final StatMonitorNotifier notifier = handler.getStatMonitorNotifier();
    assertTrue(notifier.isAlive());

    waitUntilWaiting(notifier);

    // if notification occurs then notifier woke up...
    assertEquals(0, monitor.getNotificationCount());
    handler.sampled(NanoTimer.getTime(), Collections.emptyList());

    waitForNotificationCount(monitor, 1, 2 * 1000, 10, false);
    assertEquals(1, monitor.getNotificationCount());

    // and goes back to waiting...
    waitUntilWaiting(notifier);
  }
Extracted tests from StatMonitorHandlerTest that require enableMonitorThread
geode-core/src/test/java/org/apache/geode/internal/statistics/StatMonitorHandlerWithEnabledMonitorThreadTest.java