Java Code Examples for java.util.concurrent.ThreadPoolExecutor#isTerminating()
The following examples show how to use
java.util.concurrent.ThreadPoolExecutor#isTerminating() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JadxWrapper.java From jadx with Apache License 2.0 | 6 votes |
public void saveAll(File dir, ProgressMonitor progressMonitor) { Runnable save = () -> { try { decompiler.getArgs().setRootDir(dir); ThreadPoolExecutor ex = (ThreadPoolExecutor) decompiler.getSaveExecutor(); ex.shutdown(); while (ex.isTerminating()) { long total = ex.getTaskCount(); long done = ex.getCompletedTaskCount(); progressMonitor.setProgress((int) (done * 100.0 / total)); Thread.sleep(500); } progressMonitor.close(); LOG.info("decompilation complete, freeing memory ..."); decompiler.getClasses().forEach(JavaClass::unload); LOG.info("done"); } catch (InterruptedException e) { LOG.error("Save interrupted", e); Thread.currentThread().interrupt(); } }; new Thread(save).start(); }
Example 2
Source File: ThreadPoolManager.java From phoenix with Apache License 2.0 | 5 votes |
static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) { ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName()); if (pool == null || pool.isTerminating() || pool.isShutdown()) { pool = getDefaultExecutor(builder); LOG.info("Creating new pool for " + builder.getName()); poolCache.put(builder.getName(), pool); } ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference(); return pool; }
Example 3
Source File: ThreadPoolManager.java From phoenix with Apache License 2.0 | 5 votes |
static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) { ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName()); if (pool == null || pool.isTerminating() || pool.isShutdown()) { pool = getDefaultExecutor(builder); LOGGER.info("Creating new pool for " + builder.getName()); poolCache.put(builder.getName(), pool); } ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference(); return pool; }
Example 4
Source File: ThreadPoolManager.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
static synchronized ThreadPoolExecutor getExecutor(ThreadPoolBuilder builder, Map<String, Object> poolCache) { ThreadPoolExecutor pool = (ThreadPoolExecutor) poolCache.get(builder.getName()); if (pool == null || pool.isTerminating() || pool.isShutdown()) { pool = getDefaultExecutor(builder); LOG.info("Creating new pool for " + builder.getName()); poolCache.put(builder.getName(), pool); } ((ShutdownOnUnusedThreadPoolExecutor) pool).addReference(); return pool; }
Example 5
Source File: OfferRejectedExecutionHandler.java From tomee with Apache License 2.0 | 5 votes |
@Override public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) { if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) { return; } try { if (!tpe.getQueue().offer(r, timeout, seconds)) { throw new RejectedExecutionException("Timeout waiting for executor slot: waited " + timeout + " " + seconds.toString().toLowerCase()); } } catch (final InterruptedException e) { throw new RejectedExecutionException("Interrupted waiting for executor slot"); } }