本文整理了Java中java.util.concurrent.ThreadPoolExecutor.isTerminating()
方法的一些代码示例,展示了ThreadPoolExecutor.isTerminating()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.isTerminating()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:isTerminating
[英]Returns true if this executor is in the process of terminating after #shutdown or #shutdownNow but has not completely terminated. This method may be useful for debugging. A return of true reported a sufficient period after shutdown may indicate that submitted tasks have ignored or suppressed interruption, causing this executor not to properly terminate.
[中]如果此执行器在#shutdown或#shutdownNow之后正在终止,但尚未完全终止,则返回true。此方法可能对调试有用。如果在关机后足够长的时间内返回true,则表明提交的任务忽略或抑制了中断,从而导致该执行器无法正确终止。
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean isTerminating() {
return exec instanceof ThreadPoolExecutor && ((ThreadPoolExecutor) exec).isTerminating();
}
代码示例来源:origin: jmxtrans/jmxtrans
@Override
public boolean isTerminating() {
return executor.isTerminating();
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: vipshop/vjtools
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format(
"Thread pool is EXHAUSTED!"
+ " Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d),"
+ " Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s)!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(),
e.getLargestPoolSize(), e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(),
e.isTerminating());
logger.warn(msg);
dummper.tryThreadDump(null);
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: skylot/jadx
@Override
public void run() {
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 / (double) 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();
}
}
};
代码示例来源:origin: apache/activemq
if (connectionService.isTerminating()) {
return;
代码示例来源:origin: apache/phoenix
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;
}
代码示例来源:origin: forcedotcom/phoenix
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;
}
代码示例来源:origin: javahongxi/whatsmars
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: apache/accumulo
@Override
public void run() {
while (!executor.isTerminating()) {
try {
FileSystemManager vfs = AccumuloVFSClassLoader.generateVfs();
代码示例来源:origin: apache/phoenix
@Test
public void testShutdownWithReferencesDoesNotStopExecutor() throws Exception {
Map<String, Object> cache = new HashMap<String, Object>();
ThreadPoolBuilder builder =
new ThreadPoolBuilder(name.getTableNameString(), new Configuration(false));
ThreadPoolExecutor exec = ThreadPoolManager.getExecutor(builder, cache);
assertNotNull("Got a null exector from the pool!", exec);
ThreadPoolExecutor exec2 = ThreadPoolManager.getExecutor(builder, cache);
assertTrue("Should have gotten the same executor", exec2 == exec);
exec.shutdown();
assertFalse("Executor is shutting down, even though we have a live reference!",
exec.isShutdown() || exec.isTerminating());
exec2.shutdown();
// wait 5 minutes for thread pool to shutdown
assertTrue("Executor is NOT shutting down, after releasing live reference!",
exec.awaitTermination(300, TimeUnit.SECONDS));
}
代码示例来源:origin: forcedotcom/phoenix
@Test
public void testShutdownWithReferencesDoesNotStopExecutor() throws Exception {
Map<String, Object> cache = new HashMap<String, Object>();
ThreadPoolBuilder builder =
new ThreadPoolBuilder(name.getTableNameString(), new Configuration(false));
ThreadPoolExecutor exec = ThreadPoolManager.getExecutor(builder, cache);
assertNotNull("Got a null exector from the pool!", exec);
ThreadPoolExecutor exec2 = ThreadPoolManager.getExecutor(builder, cache);
assertTrue("Should have gotten the same executor", exec2 == exec);
exec.shutdown();
assertFalse("Executor is shutting down, even though we have a live reference!",
exec.isShutdown() || exec.isTerminating());
exec2.shutdown();
// wait 5 minutes for thread pool to shutdown
assertTrue("Executor is NOT shutting down, after releasing live reference!",
exec.awaitTermination(300, TimeUnit.SECONDS));
}
代码示例来源:origin: org.gridgain/gridgain-core
/** {@inheritDoc} */
@Override public boolean isTerminating() {
assert exec != null;
return exec instanceof ThreadPoolExecutor && ((ThreadPoolExecutor) exec).isTerminating();
}
代码示例来源:origin: net.anwiba.commons/anwiba-commons-core
public static QueueState get(final ThreadPoolExecutor executor) {
if (executor.isShutdown()) {
return QueueState.SHUTDOWN;
}
if (executor.isTerminating()) {
return QueueState.TERMINATING;
}
if (executor.isShutdown()) {
return QueueState.TERMINATED;
}
return QueueState.ACTIVE;
}
代码示例来源:origin: i2p/i2p.i2p
if (_executor != null && !_executor.isTerminating() && !_executor.isShutdown())
_executor.shutdownNow();
代码示例来源:origin: org.apache.tomee/openejb-server
@Override
public void rejectedExecution(final Runnable r, final ThreadPoolExecutor tpe) {
if (null == r || null == tpe || tpe.isShutdown() || tpe.isTerminated() || tpe.isTerminating()) {
return;
}
try {
tpe.getQueue().offer(r, 20, TimeUnit.SECONDS);
} catch (InterruptedException e) {
//Ignore
}
}
});
代码示例来源:origin: jpos/jPOS
public boolean isTerminating() throws NotFoundException {
ThreadPoolExecutor executorService = getThreadPoolExecutor(getName(),
ThreadPoolExecutor.class);
return executorService.isTerminating();
}
代码示例来源:origin: linux-china/dubbo3
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!" ,
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
throw new RejectedExecutionException(msg);
}
代码示例来源:origin: com.alibaba/dubbo
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor e) {
String msg = String.format("Thread pool is EXHAUSTED!" +
" Thread Name: %s, Pool Size: %d (active: %d, core: %d, max: %d, largest: %d), Task: %d (completed: %d)," +
" Executor status:(isShutdown:%s, isTerminated:%s, isTerminating:%s), in %s://%s:%d!",
threadName, e.getPoolSize(), e.getActiveCount(), e.getCorePoolSize(), e.getMaximumPoolSize(), e.getLargestPoolSize(),
e.getTaskCount(), e.getCompletedTaskCount(), e.isShutdown(), e.isTerminated(), e.isTerminating(),
url.getProtocol(), url.getIp(), url.getPort());
logger.warn(msg);
dumpJStack();
throw new RejectedExecutionException(msg);
}
内容来源于网络,如有侵权,请联系作者删除!