本文整理汇总了Java中org.apache.camel.spi.ThreadPoolProfile.getRejectedExecutionHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolProfile.getRejectedExecutionHandler方法的具体用法?Java ThreadPoolProfile.getRejectedExecutionHandler怎么用?Java ThreadPoolProfile.getRejectedExecutionHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.ThreadPoolProfile
的用法示例。
在下文中一共展示了ThreadPoolProfile.getRejectedExecutionHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newScheduledThreadPool
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile profile, ThreadFactory threadFactory) {
RejectedExecutionHandler rejectedExecutionHandler = profile.getRejectedExecutionHandler();
if (rejectedExecutionHandler == null) {
rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
}
ScheduledThreadPoolExecutor answer = new RejectableScheduledThreadPoolExecutor(profile.getPoolSize(), threadFactory, rejectedExecutionHandler);
answer.setRemoveOnCancelPolicy(true);
// need to wrap the thread pool in a sized to guard against the problem that the
// JDK created thread pool has an unbounded queue (see class javadoc), which mean
// we could potentially keep adding tasks, and run out of memory.
if (profile.getMaxPoolSize() > 0) {
return new SizedScheduledExecutorService(answer, profile.getMaxQueueSize());
} else {
return answer;
}
}
示例2: newScheduledThreadPool
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
@Override
public ScheduledExecutorService newScheduledThreadPool(ThreadPoolProfile profile, ThreadFactory threadFactory) {
RejectedExecutionHandler rejectedExecutionHandler = profile.getRejectedExecutionHandler();
if (rejectedExecutionHandler == null) {
rejectedExecutionHandler = new ThreadPoolExecutor.CallerRunsPolicy();
}
ScheduledThreadPoolExecutor answer = new RejectableScheduledThreadPoolExecutor(
profile.getPoolSize(), managedThreadFactory, rejectedExecutionHandler);
if (profile.getMaxPoolSize() > 0) {
return new SizedScheduledExecutorService(answer, profile.getMaxQueueSize());
} else {
return answer;
}
}