Code example for ScheduledExecutorService

Methods: awaitTermination, shutdown

0
     * @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.shutdown();
        executor.awaitTermination(timeout, unit);
    } 
 
    @Override 
    public void shutdown() { 
        executor.shutdown();
        super.shutdown(); 
    } 
 
    /** 
     * The method called when a a poll is scheduled to occur. 
     */ 
    @Override 
    public abstract void run(); 
}