@VisibleForTesting
  public void createSchedulerAndScheduleMonitor(String monitorName, MonitorConfig monitorConfig, long schedulingIntervalInMs)
      throws InstantiationException {
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
        .setNameFormat("MonitorThread-%d")
        .build();

    ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1, threadFactory);
    scheduledExecutors.add(scheduledExecutorService);

    scheduledExecutorService
        .scheduleAtFixedRate(getRunnable(instantiateMonitor(monitorName, monitorConfig, metricsRegistry)),
            0, schedulingIntervalInMs, TimeUnit.MILLISECONDS);
  }
Creates a ScheduledThreadPoolExecutor with core pool size 1 and schedules the monitor to run every schedulingIntervalInMs
samza-rest/src/main/java/org/apache/samza/monitor/SamzaMonitorService.java