Code example for ExecutorService

Methods: awaitTerminationisShutdownshutdownshutdownNow

0
 
    private ConcurrentUtil() { 
    } 
 
    public static void destroy(ExecutorService executor) {
        executor.shutdown();
        try { 
            executor.awaitTermination(TIMEOUT, TimeUnit.SECONDS);
        } catch (final InterruptedException e) {
            Thread.currentThread().interrupt();
        } 
        if (!executor.isShutdown())
            executor.shutdownNow();
    } 
 
    /** 
     * If the Throwable is an Error, throw it; if it is a RuntimeException 
     * return it, otherwise throw IllegalStateException 
     */ 
 
Experience pair programming with AI  Get Codota for Java