Code example for ScheduledExecutorService

Methods: scheduleWithFixedDelay

     * @param period    the amount of time between polls 
     * @param unit      the unit for {@code period} 
    public void start(long period, TimeUnit unit) {
        executor.scheduleWithFixedDelay(this, period, period, unit);
     * Shuts down the reporter polling, waiting the specific amount of time for any current polls to 
     * complete. 
     * @param timeout    the maximum time to wait 
     * @param unit       the unit for {@code timeout} 
     * @throws InterruptedException if interrupted while waiting 
    public void shutdown(long timeout, TimeUnit unit) throws InterruptedException {
        executor.awaitTermination(timeout, unit);
Connect your IDE to all the code out there  Get Codota for Java