本文整理了Java中java.util.concurrent.ScheduledExecutorService.awaitTermination()
方法的一些代码示例,展示了ScheduledExecutorService.awaitTermination()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScheduledExecutorService.awaitTermination()
方法的具体详情如下:
包路径:java.util.concurrent.ScheduledExecutorService
类名称:ScheduledExecutorService
方法名:awaitTermination
暂无
代码示例来源:origin: square/okhttp
/**
* For testing: force this web socket to release its threads.
*/
void tearDown() throws InterruptedException {
if (cancelFuture != null) {
cancelFuture.cancel(false);
}
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}
代码示例来源:origin: apache/flink
void stop() {
executor.shutdown();
try {
if (!executor.awaitTermination(1, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (InterruptedException ignored) {
executor.shutdownNow();
}
}
代码示例来源:origin: spotify/helios
@Override
protected void shutDown() throws Exception {
zkWriterExecutor.shutdownNow();
zkWriterExecutor.awaitTermination(1, TimeUnit.MINUTES);
}
代码示例来源:origin: apache/storm
@Override
public void shutdown() {
executor.shutdown();
try {
if (!executor.awaitTermination(2, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (InterruptedException ie) {
executor.shutdownNow();
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: prestodb/presto
/**
* For testing: force this web socket to release its threads.
*/
void tearDown() throws InterruptedException {
if (cancelFuture != null) {
cancelFuture.cancel(false);
}
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}
代码示例来源:origin: OpenHFT/Chronicle-Queue
@Override
public void close() {
THREAD_LOCAL_CLEANER_EXECUTOR_SERVICE.shutdownNow();
try {
THREAD_LOCAL_CLEANER_EXECUTOR_SERVICE.awaitTermination(1, TimeUnit.SECONDS);
} catch (InterruptedException ignore) {
}
}
}
代码示例来源:origin: apache/storm
public void shutdown() {
LOG.debug("Shutting down WaterMarkEventGenerator");
executorService.shutdown();
try {
if (!executorService.awaitTermination(2, TimeUnit.SECONDS)) {
executorService.shutdownNow();
}
} catch (InterruptedException ie) {
executorService.shutdownNow();
Thread.currentThread().interrupt();
}
}
}
代码示例来源:origin: apache/storm
@Override
public void close() {
_pendingFlusher.shutdown();
try {
_pendingFlusher.awaitTermination(5, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted while awaiting flusher shutdown", e);
}
}
}
代码示例来源:origin: spotify/helios
@Override
protected void shutDown() throws Exception {
if (future != null) {
future.cancel(true);
}
executorService.shutdownNow();
executorService.awaitTermination(1, DAYS);
}
代码示例来源:origin: alibaba/jstorm
@Override
public void shutdown() {
executor.shutdown();
try {
if (!executor.awaitTermination(2, TimeUnit.SECONDS)) {
executor.shutdownNow();
}
} catch (InterruptedException ie) {
executor.shutdownNow();
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: jamesdbloom/mockserver
public synchronized void shutdown() {
if (scheduler != null) {
scheduler.shutdown();
try {
scheduler.awaitTermination(500, MILLISECONDS);
} catch (InterruptedException ignore) {
// ignore interrupted exception
}
scheduler = null;
}
}
代码示例来源:origin: springside/springside4
/**
* 启动停止任务.
*/
public void stop() {
if (!started) {
throw new IllegalStateException("Scheduler hadn't been started before");
}
executor.shutdownNow();
try {
if (executor.awaitTermination(5, TimeUnit.SECONDS)) {
logger.info("metric reporters stopped.");
} else {
logger.info("metric reporters can't stop in 5 seconds, force stopped.");
}
started = false;
} catch (InterruptedException ignored) {
// do nothing
}
}
代码示例来源:origin: apache/storm
private void closeFlushScheduler() {
if (flushScheduler != null) {
flushScheduler.shutdown();
try {
if (!flushScheduler.awaitTermination(2, TimeUnit.SECONDS)) {
flushScheduler.shutdownNow();
}
} catch (InterruptedException ie) {
// (Re-)Cancel if current thread also interrupted
flushScheduler.shutdownNow();
// Preserve interrupt status
Thread.currentThread().interrupt();
}
}
}
}
代码示例来源:origin: apache/incubator-gobblin
/** Stop the service. */
@Override
protected void shutDown()
throws Exception {
this.scheduledExecutorPool.shutdown();
this.scheduledExecutorPool.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS);
}
}
代码示例来源:origin: apache/hive
@VisibleForTesting
static synchronized boolean stopCacheUpdateService(long timeout) {
boolean tasksStoppedBeforeShutdown = false;
if (cacheUpdateMaster != null) {
LOG.info("CachedStore: shutting down cache update service");
try {
tasksStoppedBeforeShutdown =
cacheUpdateMaster.awaitTermination(timeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
LOG.info("CachedStore: cache update service was interrupted while waiting for tasks to "
+ "complete before shutting down. Will make a hard stop now.");
}
cacheUpdateMaster.shutdownNow();
cacheUpdateMaster = null;
}
return tasksStoppedBeforeShutdown;
}
代码示例来源:origin: azkaban/azkaban
public void shutdown() {
this.scheduler.shutdown();
try {
if (!this.scheduler.awaitTermination(60, TimeUnit.SECONDS)) {
this.scheduler.shutdownNow();
}
} catch (final InterruptedException ex) {
this.scheduler.shutdownNow();
Thread.currentThread().interrupt();
}
}
代码示例来源:origin: apache/incubator-gobblin
/** Stop the service. */
@Override
protected void shutDown() throws Exception {
this.scheduledExecutor.shutdown();
this.scheduledExecutor.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS);
}
代码示例来源:origin: Alluxio/alluxio
/**
* Stops {@link DailyMetadataBackup}.
*/
public void stop() {
if (mBackup != null) {
mBackup.cancel(true);
mBackup = null;
}
LOG.info("Daily metadata backup stopped");
mScheduledExecutor.shutdownNow();
String waitForMessage = "waiting for daily metadata backup executor service to shut down";
try {
if (!mScheduledExecutor.awaitTermination(SHUTDOWN_TIMEOUT_MS, TimeUnit.MILLISECONDS)) {
LOG.warn("Timed out " + waitForMessage);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOG.warn("Interrupted while " + waitForMessage);
}
}
}
代码示例来源:origin: oracle/helidon
/**
* Shutdowns {@code executor} and waits for it.
*
* @param executor executor to be shutdown.
*/
public static void shutdownExecutor(ScheduledExecutorService executor) {
executor.shutdown();
try {
executor.awaitTermination(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
executor.shutdownNow();
}
}
代码示例来源:origin: internetarchive/heritrix3
public void stop() {
executor.shutdown();
try {
while (!executor.awaitTermination(10, TimeUnit.SECONDS));
} catch (InterruptedException e) {
// do nothing
}
}
内容来源于网络,如有侵权,请联系作者删除!