本文整理汇总了Java中com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination方法的典型用法代码示例。如果您正苦于以下问题:Java MoreExecutors.shutdownAndAwaitTermination方法的具体用法?Java MoreExecutors.shutdownAndAwaitTermination怎么用?Java MoreExecutors.shutdownAndAwaitTermination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.util.concurrent.MoreExecutors
的用法示例。
在下文中一共展示了MoreExecutors.shutdownAndAwaitTermination方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
/** Stops receiving messages from the inspector and closes it. */
@Override
public void close() throws IOException {
try {
// Canceling the future marks the future done and the messenger "closed".
// If it can't be cancelled, it must have terminated prematurely, so raise an exception.
if (!receiveFuture.cancel(false)) {
Futures.getChecked(receiveFuture, IOException.class);
}
} finally {
try {
MoreExecutors.shutdownAndAwaitTermination(executor, 5, SECONDS);
} finally {
inspector.close();
}
}
}
示例2: close
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Override
public void close() {
if (!MoreExecutors.shutdownAndAwaitTermination(executor, 5, SECONDS)) {
log.severe("Executor did not terminate successfully");
}
if (browser != null) {
try {
browser.close();
} catch (BrowserException e) {
throw new WebDriverException(e);
}
}
}
示例3: shutdownExecutorService
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
public static void shutdownExecutorService(Engine engine, Object named, ExecutorService executorService) {
MoreExecutors.shutdownAndAwaitTermination(executorService, engine.getDefaultParameters().getExecutorShutdownTimeout(),
TimeUnit.SECONDS);
if (!executorService.isTerminated()) {
logger.warn("Executor for {} hasn't shutdown gracefully.", named);
}
}
示例4: gracefulShutdown
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
/**
* @see gracefulShutdown
*/
public static boolean gracefulShutdown(@Nullable ExecutorService threadPool, int shutdownTimeout,
TimeUnit timeUnit) {
return threadPool != null ? MoreExecutors.shutdownAndAwaitTermination(threadPool, shutdownTimeout, timeUnit)
: true;
}