本文整理汇总了Java中org.apache.camel.spi.ThreadPoolProfile.getPoolSize方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolProfile.getPoolSize方法的具体用法?Java ThreadPoolProfile.getPoolSize怎么用?Java ThreadPoolProfile.getPoolSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.spi.ThreadPoolProfile
的用法示例。
在下文中一共展示了ThreadPoolProfile.getPoolSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例3: lookupScheduled
import org.apache.camel.spi.ThreadPoolProfile; //导入方法依赖的package包/类
public ScheduledExecutorService lookupScheduled(Object source, String name, String executorServiceRef) {
ScheduledExecutorService answer = camelContext.getRegistry().lookupByNameAndType(executorServiceRef, ScheduledExecutorService.class);
if (answer == null) {
ThreadPoolProfile profile = getThreadPoolProfile(executorServiceRef);
if (profile != null) {
Integer poolSize = profile.getPoolSize();
if (poolSize == null) {
poolSize = getDefaultThreadPoolProfile().getPoolSize();
}
answer = newScheduledThreadPool(source, name, poolSize);
}
}
return answer;
}