本文整理汇总了Java中com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor方法的典型用法代码示例。如果您正苦于以下问题:Java MoreExecutors.sameThreadExecutor方法的具体用法?Java MoreExecutors.sameThreadExecutor怎么用?Java MoreExecutors.sameThreadExecutor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.util.concurrent.MoreExecutors
的用法示例。
在下文中一共展示了MoreExecutors.sameThreadExecutor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSpyingQJM
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
private QuorumJournalManager createSpyingQJM()
throws IOException, URISyntaxException {
AsyncLogger.Factory spyFactory = new AsyncLogger.Factory() {
@Override
public AsyncLogger createLogger(Configuration conf, NamespaceInfo nsInfo,
String journalId, InetSocketAddress addr) {
AsyncLogger logger = new IPCLoggerChannel(conf, nsInfo, journalId, addr) {
protected ExecutorService createSingleThreadExecutor() {
// Don't parallelize calls to the quorum in the tests.
// This makes the tests more deterministic.
return MoreExecutors.sameThreadExecutor();
}
};
return Mockito.spy(logger);
}
};
return closeLater(new QuorumJournalManager(
conf, cluster.getQuorumJournalURI(JID), FAKE_NSINFO, spyFactory));
}
示例2: createSingleThreadExecutor
import com.google.common.util.concurrent.MoreExecutors; //导入方法依赖的package包/类
@Override
protected ExecutorService createSingleThreadExecutor() {
return MoreExecutors.sameThreadExecutor();
}