code: public void run() {
          scheduledExecutorService = Executors.newScheduledThreadPool(1);
          scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
              @Override
              public void run() {
                  SystemInfo systemInfo = new SystemInfo();
                  HardwareMetric hardwareMetric = HardwareMetric.fromSystem(systemInfo,nameProvider.nextName());
                  File hardwareFile = new File(outputDirectory,hardwareMetric.getName() + ".yml");
                  try {
                      objectMapper.writeValue(hardwareFile,hardwareMetric);
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          },0,pollEveryMillis, TimeUnit.MILLISECONDS);
      }
docs: Run the polling in the background as a thread pool
  running every {@link #pollEveryMillis} milliseconds