@Override public void run() { Instant endOfProcessDate = new Date().toInstant().plus(duration); LOGGER.info("The process will finish at: " + endOfProcessDate); while (!new Date().toInstant().isAfter(endOfProcessDate)) { try { Thread.sleep(SLEEP_TIME * 1000); } catch (InterruptedException e) { LOGGER.warn("Sleep interrupted: premature stop will occured."); } } LOGGER.info("The process will now stop."); this.inspectBuilds.switchOff(); this.inspectJobs.switchOff(); this.buildRunner.switchOff(); if (this.endProcessNotifier != null) { this.endProcessNotifier.notifyEnd(); } } }