/** * Returns <code>true</code> if the given service was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ExecutorService service, long timeout, TimeUnit timeUnit) { if (service != null) { service.shutdown(); if (awaitTermination(service, timeout, timeUnit)) return true; service.shutdownNow(); return awaitTermination(service, timeout, timeUnit); } return false; }
private static boolean awaitTermination( final ThreadPool threadPool, final long timeout, final TimeUnit timeUnit) { try { if (threadPool.awaitTermination(timeout, timeUnit)) { return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
toClose.add(() -> { try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
/** * Returns <code>true</code> if the given service was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ExecutorService service, long timeout, TimeUnit timeUnit) { if (service != null) { service.shutdown(); if (awaitTermination(service, timeout, timeUnit)) return true; service.shutdownNow(); return awaitTermination(service, timeout, timeUnit); } return false; }
/** * Returns <code>true</code> if the given service was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ExecutorService service, long timeout, TimeUnit timeUnit) { if (service != null) { service.shutdown(); if (awaitTermination(service, timeout, timeUnit)) return true; service.shutdownNow(); return awaitTermination(service, timeout, timeUnit); } return false; }
/** * Returns <code>true</code> if the given service was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ExecutorService service, long timeout, TimeUnit timeUnit) { if (service != null) { service.shutdown(); if (awaitTermination(service, timeout, timeUnit)) return true; service.shutdownNow(); return awaitTermination(service, timeout, timeUnit); } return false; }
private static boolean awaitTermination( final ThreadPool pool, final long timeout, final TimeUnit timeUnit) { try { if (pool.awaitTermination(timeout, timeUnit)) { return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return false; }
private static boolean awaitTermination( final ThreadPool threadPool, final long timeout, final TimeUnit timeUnit) { try { if (threadPool.awaitTermination(timeout, timeUnit)) { return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } return false; }
static final class Fields { static final String TYPE = "type"; static final String MIN = "min"; static final String MAX = "max"; static final String KEEP_ALIVE = "keep_alive"; static final String QUEUE_SIZE = "queue_size"; } }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) return true; // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { pool.shutdown(); try { if (pool.awaitTermination(timeout, timeUnit)) { return true; } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } // last resort pool.shutdownNow(); } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
/** * Returns <code>true</code> if the given pool was terminated successfully. If the termination timed out, * the service is <code>null</code> this method will return <code>false</code>. */ public static boolean terminate(ThreadPool pool, long timeout, TimeUnit timeUnit) { if (pool != null) { try { pool.shutdown(); if (awaitTermination(pool, timeout, timeUnit)) { return true; } // last resort pool.shutdownNow(); return awaitTermination(pool, timeout, timeUnit); } finally { IOUtils.closeWhileHandlingException(pool); } } return false; }
toClose.add(() -> { try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
toClose.add(() -> { try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
toClose.add(() -> { try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
injector.getInstance(ThreadPool.class).shutdown(); try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {
injector.getInstance(ThreadPool.class).shutdown(); try { injector.getInstance(ThreadPool.class).awaitTermination(10, TimeUnit.SECONDS); } catch (InterruptedException e) {