本文整理了Java中java.util.concurrent.ThreadPoolExecutor.awaitTermination()
方法的一些代码示例,展示了ThreadPoolExecutor.awaitTermination()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadPoolExecutor.awaitTermination()
方法的具体详情如下:
包路径:java.util.concurrent.ThreadPoolExecutor
类名称:ThreadPoolExecutor
方法名:awaitTermination
暂无
代码示例来源:origin: skylot/jadx
@Override
public Boolean call() throws Exception {
runJob();
executor.shutdown();
return executor.awaitTermination(5, TimeUnit.DAYS);
}
});
代码示例来源:origin: thinkaurelius/titan
@Override
public void close() throws Exception {
processor.shutdown();
processor.awaitTermination(shutdownWaitMS,TimeUnit.MILLISECONDS);
if (!processor.isTerminated()) {
//log.error("Processor did not terminate in time");
processor.shutdownNow();
}
}
}
代码示例来源:origin: qunarcorp/qmq
@Override
public void destroy() {
executorService.shutdown();
try {
executorService.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOGGER.error("Shutdown nettySenderExecutorService interrupted.");
}
}
代码示例来源:origin: JanusGraph/janusgraph
@Override
public void close() throws Exception {
processor.shutdown();
processor.awaitTermination(SHUTDOWN_WAIT_MS,TimeUnit.MILLISECONDS);
if (!processor.isTerminated()) {
//log.error("Processor did not terminate in time");
processor.shutdownNow();
}
}
}
代码示例来源:origin: RipMeApp/ripme
/**
* Tries to shutdown threadpool.
*/
public void waitForThreads() {
threadPool.shutdown();
try {
threadPool.awaitTermination(3600, TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.error("[!] Interrupted while waiting for threads to finish: ", e);
}
}
}
代码示例来源:origin: org.apache.hadoop/hadoop-common
@Override
protected void processArguments(LinkedList<PathData> args)
throws IOException {
executor = new ThreadPoolExecutor(numThreads, numThreads, 1,
TimeUnit.SECONDS, new ArrayBlockingQueue<>(1024),
new ThreadPoolExecutor.CallerRunsPolicy());
super.processArguments(args);
// issue the command and then wait for it to finish
executor.shutdown();
try {
executor.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);
} catch (InterruptedException e) {
executor.shutdownNow();
displayError(e);
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: ethereum/ethereumj
/**
* Shutdowns executors and waits until all pipeline
* submitted tasks complete
* @throws InterruptedException
*/
public void join() throws InterruptedException {
exec.shutdown();
exec.awaitTermination(10, TimeUnit.MINUTES);
if (next != null) next.join();
}
代码示例来源:origin: apache/hbase
executorService.shutdown();
while (msLeftToWait >= 0) {
try {
executorService.awaitTermination(msLeftToWait, TimeUnit.MILLISECONDS);
break;
} catch (InterruptedException ix) {
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Wait for all threads to finish.
*
* @param destroyThreadpool -- if true, then destroy the worker threads
* so that the main thread can shutdown.
*/
public void join(boolean destroyThreadpool) {
// Make blocking calls to the last processes that are running
if ( ! threadPool.isShutdown()) {
try {
for (int i = nThreads; i > 0; --i) {
idleProcessors.take();
}
if (destroyThreadpool) {
threadPool.shutdown();
// Sanity check. The threadpool should be done after iterating over
// the processors.
threadPool.awaitTermination(10, TimeUnit.SECONDS);
} else {
// Repopulate the list of processors
for (int i = 0; i < nThreads; ++i) {
idleProcessors.put(i);
}
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: Alluxio/alluxio
mPool.shutdown();
try {
mPool.awaitTermination(Long.MAX_VALUE, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOG.warn("Copy thread pool is interrupted in shutdown.", e);
代码示例来源:origin: crossoverJie/cim
@Override
public void process(String msg) {
LOGGER.info("系统关闭中。。。。");
routeRequest.offLine();
msgLogger.stop();
executor.shutdown();
try {
while (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
LOGGER.info("线程池关闭中。。。。");
}
cimClient.close();
} catch (InterruptedException e) {
LOGGER.error("InterruptedException", e);
}
System.exit(0);
}
}
代码示例来源:origin: FlowCI/flow-platform
executor.shutdown();
if (!executor.awaitTermination(DEFAULT_SHUTDOWN_WAITING_SECONDS, TimeUnit.SECONDS)) {
executor.shutdownNow();
代码示例来源:origin: crossoverJie/cim
/**
* 关闭系统
*/
@Override
public void shutdown() {
LOGGER.info("系统关闭中。。。。");
routeRequest.offLine();
msgLogger.stop();
executor.shutdown();
try {
while (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
LOGGER.info("线程池关闭中。。。。");
}
cimClient.close();
} catch (InterruptedException e) {
LOGGER.error("InterruptedException", e);
}
System.exit(0);
}
代码示例来源:origin: crossoverJie/JCSprout
productExecutor.shutdown();
while (!productExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
System.out.println("线程还在执行。。。");
代码示例来源:origin: stanfordnlp/CoreNLP
threadPool.shutdown();
threadPool.awaitTermination(10, TimeUnit.SECONDS);
代码示例来源:origin: apache/hive
@Override
public synchronized void stop() {
super.stop();
shutdownTimeoutChecker();
if (backgroundOperationPool != null) {
backgroundOperationPool.shutdown();
long timeout = hiveConf.getTimeVar(
ConfVars.HIVE_SERVER2_ASYNC_EXEC_SHUTDOWN_TIMEOUT, TimeUnit.SECONDS);
try {
backgroundOperationPool.awaitTermination(timeout, TimeUnit.SECONDS);
} catch (InterruptedException e) {
LOG.warn("HIVE_SERVER2_ASYNC_EXEC_SHUTDOWN_TIMEOUT = " + timeout +
" seconds has been exceeded. RUNNING background operations will be shut down", e);
}
backgroundOperationPool = null;
}
cleanupLoggingRootDir();
}
代码示例来源:origin: apache/hbase
@Override
protected void doStop() {
disconnect(); // don't call super.doStop()
if (this.conn != null) {
try {
this.conn.close();
this.conn = null;
} catch (IOException e) {
LOG.warn("Failed to close the connection");
}
}
// Allow currently running replication tasks to finish
exec.shutdown();
try {
exec.awaitTermination(maxTerminationWait, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
}
// Abort if the tasks did not terminate in time
if (!exec.isTerminated()) {
String errMsg = "HBaseInterClusterReplicationEndpoint termination failed. The " +
"ThreadPoolExecutor failed to finish all tasks within " + maxTerminationWait + "ms. " +
"Aborting to prevent Replication from deadlocking. See HBASE-16081.";
abortable.abort(errMsg, new IOException(errMsg));
}
notifyStopped();
}
代码示例来源:origin: apache/hbase
tpe.shutdown();
int threadWakeFrequency = conf.getInt(HConstants.THREAD_WAKE_FREQUENCY,
60 * 1000);
while (!tpe.awaitTermination(threadWakeFrequency,
TimeUnit.MILLISECONDS)) {
代码示例来源:origin: com.zaxxer/HikariCP
addConnectionExecutor.shutdown();
addConnectionExecutor.awaitTermination(getLoginTimeout(), SECONDS);
closeConnectionExecutor.shutdown();
closeConnectionExecutor.awaitTermination(10L, SECONDS);
代码示例来源:origin: killme2008/xmemcached
public void stop() {
this.threadPool.shutdown();
try {
this.threadPool.awaitTermination(1000, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
内容来源于网络,如有侵权,请联系作者删除!