MonitorRegistryMetricPoller implements MetricPoller { public void shutdown() { if (service != null) { service.shutdownNow(); } } MonitorRegistryMetricPoller();  MonitorRegistryMetricPoller(MonitorRegistry registry);  MonitorRegistryMetricPoller(MonitorRegistry registry, long cacheTTL, TimeUnit unit);  MonitorRegistryMetricPoller(MonitorRegistry registry, long cacheTTL, TimeUnit unit,
                                     boolean useLimiter);  MonitorRegistryMetricPoller(
      MonitorRegistry registry, long cacheTTL, TimeUnit unit, boolean useLimiter,
      Clock clock); List<Metric> poll(MetricFilter filter); List<Metric> poll(MetricFilter filter, boolean reset); void shutdown();  }
@Test(enabled = false) public void testShutdown() throws Exception { MonitorRegistry registry = new BasicMonitorRegistry(); registry.register(Monitors.newCounter("test")); final String threadPrefix = "ServoMonitorGetValueLimiter"; Thread.sleep(1000); int baseCount = countThreadsWithName(threadPrefix); MonitorRegistryMetricPoller[] pollers = new MonitorRegistryMetricPoller[10]; for (int i = 0; i < pollers.length; ++i) { pollers[i] = new MonitorRegistryMetricPoller(registry); pollers[i].poll(MATCH_ALL); } int retries = 0; for (; retries < 10; ++retries) { int currentThreads = countThreadsWithName(threadPrefix); if (currentThreads >= 10 + baseCount) { break; } System.err.println(String.format("currentThreads: %d/%d", currentThreads, baseCount)); Thread.sleep(200); } assertTrue(retries < 10); for (MonitorRegistryMetricPoller poller : pollers) { poller.shutdown(); } Thread.sleep(1000); assertTrue(countThreadsWithName(threadPrefix) <= baseCount); }