rename maxPoolNum to maximumPoolSize (#1073)

pull/1076/head
yangsanity 3 years ago committed by GitHub
parent 594208224a
commit 68a635b4ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -63,7 +63,7 @@ public class AbstractBuildThreadPoolTemplate {
ThreadPoolExecutor executorService; ThreadPoolExecutor executorService;
try { try {
executorService = new ThreadPoolExecutorTemplate(initParam.getCorePoolNum(), executorService = new ThreadPoolExecutorTemplate(initParam.getCorePoolNum(),
initParam.getMaxPoolNum(), initParam.getMaximumPoolSize(),
initParam.getKeepAliveTime(), initParam.getKeepAliveTime(),
initParam.getTimeUnit(), initParam.getTimeUnit(),
initParam.getWorkQueue(), initParam.getWorkQueue(),
@ -97,7 +97,7 @@ public class AbstractBuildThreadPoolTemplate {
FastThreadPoolExecutor fastThreadPoolExecutor; FastThreadPoolExecutor fastThreadPoolExecutor;
try { try {
fastThreadPoolExecutor = new FastThreadPoolExecutor(initParam.getCorePoolNum(), fastThreadPoolExecutor = new FastThreadPoolExecutor(initParam.getCorePoolNum(),
initParam.getMaxPoolNum(), initParam.getMaximumPoolSize(),
initParam.getKeepAliveTime(), initParam.getKeepAliveTime(),
initParam.getTimeUnit(), initParam.getTimeUnit(),
taskQueue, taskQueue,
@ -123,7 +123,7 @@ public class AbstractBuildThreadPoolTemplate {
try { try {
dynamicThreadPoolExecutor = new DynamicThreadPoolExecutor( dynamicThreadPoolExecutor = new DynamicThreadPoolExecutor(
initParam.getCorePoolNum(), initParam.getCorePoolNum(),
initParam.getMaxPoolNum(), initParam.getMaximumPoolSize(),
initParam.getKeepAliveTime(), initParam.getKeepAliveTime(),
initParam.getTimeUnit(), initParam.getTimeUnit(),
initParam.getExecuteTimeOut(), initParam.getExecuteTimeOut(),
@ -150,7 +150,7 @@ public class AbstractBuildThreadPoolTemplate {
private Integer corePoolNum; private Integer corePoolNum;
private Integer maxPoolNum; private Integer maximumPoolSize;
private Long keepAliveTime; private Long keepAliveTime;

@ -41,7 +41,7 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
private int corePoolSize = calculateCoreNum(); private int corePoolSize = calculateCoreNum();
private int maxPoolSize = corePoolSize + (corePoolSize >> 1); private int maximumPoolSize = corePoolSize + (corePoolSize >> 1);
private long keepAliveTime = 30000L; private long keepAliveTime = 30000L;
@ -150,16 +150,24 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
return this; return this;
} }
/**
* @deprecated Use {@link #maximumPoolSize}
*/
@Deprecated
public ThreadPoolBuilder maxPoolNum(int maximumPoolSize) {
return this.maximumPoolSize(maximumPoolSize);
}
/** /**
* Max pool num. * Max pool num.
* *
* @param maxPoolSize max pool num * @param maximumPoolSize max pool num
* @return thread-pool builder * @return thread-pool builder
*/ */
public ThreadPoolBuilder maxPoolNum(int maxPoolSize) { public ThreadPoolBuilder maximumPoolSize(int maximumPoolSize) {
this.maxPoolSize = maxPoolSize; this.maximumPoolSize = maximumPoolSize;
if (maxPoolSize < this.corePoolSize) { if (maximumPoolSize < this.corePoolSize) {
this.corePoolSize = maxPoolSize; this.corePoolSize = maximumPoolSize;
} }
return this; return this;
} }
@ -172,7 +180,7 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
public ThreadPoolBuilder singlePool() { public ThreadPoolBuilder singlePool() {
int singleNum = 1; int singleNum = 1;
this.corePoolSize = singleNum; this.corePoolSize = singleNum;
this.maxPoolSize = singleNum; this.maximumPoolSize = singleNum;
return this; return this;
} }
@ -185,7 +193,7 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
public ThreadPoolBuilder singlePool(String threadNamePrefix) { public ThreadPoolBuilder singlePool(String threadNamePrefix) {
int singleNum = 1; int singleNum = 1;
this.corePoolSize = singleNum; this.corePoolSize = singleNum;
this.maxPoolSize = singleNum; this.maximumPoolSize = singleNum;
this.threadNamePrefix = threadNamePrefix; this.threadNamePrefix = threadNamePrefix;
return this; return this;
} }
@ -194,12 +202,12 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
* Pool thread size. * Pool thread size.
* *
* @param corePoolSize core pool size * @param corePoolSize core pool size
* @param maxPoolSize max pool size * @param maximumPoolSize max pool size
* @return thread-pool builder * @return thread-pool builder
*/ */
public ThreadPoolBuilder poolThreadSize(int corePoolSize, int maxPoolSize) { public ThreadPoolBuilder poolThreadSize(int corePoolSize, int maximumPoolSize) {
this.corePoolSize = corePoolSize; this.corePoolSize = corePoolSize;
this.maxPoolSize = maxPoolSize; this.maximumPoolSize = maximumPoolSize;
return this; return this;
} }
@ -438,7 +446,7 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
initParam = new AbstractBuildThreadPoolTemplate.ThreadPoolInitParam(builder.threadFactory); initParam = new AbstractBuildThreadPoolTemplate.ThreadPoolInitParam(builder.threadFactory);
} }
initParam.setCorePoolNum(builder.corePoolSize) initParam.setCorePoolNum(builder.corePoolSize)
.setMaxPoolNum(builder.maxPoolSize) .setMaximumPoolSize(builder.maximumPoolSize)
.setKeepAliveTime(builder.keepAliveTime) .setKeepAliveTime(builder.keepAliveTime)
.setCapacity(builder.capacity) .setCapacity(builder.capacity)
.setExecuteTimeOut(builder.executeTimeOut) .setExecuteTimeOut(builder.executeTimeOut)

@ -79,7 +79,7 @@ public class ThreadPoolTaskExecutorAdapter implements DynamicThreadPoolAdapter {
ThreadPoolBuilder threadPoolBuilder = ThreadPoolBuilder.builder() ThreadPoolBuilder threadPoolBuilder = ThreadPoolBuilder.builder()
.dynamicPool() .dynamicPool()
.corePoolSize(threadPoolTaskExecutor.getCorePoolSize()) .corePoolSize(threadPoolTaskExecutor.getCorePoolSize())
.maxPoolNum(threadPoolTaskExecutor.getMaxPoolSize()) .maximumPoolSize(threadPoolTaskExecutor.getMaxPoolSize())
.keepAliveTime(threadPoolTaskExecutor.getKeepAliveSeconds()) .keepAliveTime(threadPoolTaskExecutor.getKeepAliveSeconds())
.timeUnit(TimeUnit.SECONDS) .timeUnit(TimeUnit.SECONDS)
.allowCoreThreadTimeOut(threadPoolExecutor.allowsCoreThreadTimeOut()) .allowCoreThreadTimeOut(threadPoolExecutor.allowsCoreThreadTimeOut())

@ -40,7 +40,7 @@ public abstract class AbstractDynamicThreadPoolService implements DynamicThreadP
ThreadPoolExecutor dynamicThreadPoolExecutor = ThreadPoolBuilder.builder() ThreadPoolExecutor dynamicThreadPoolExecutor = ThreadPoolBuilder.builder()
.threadPoolId(registerParameter.getThreadPoolId()) .threadPoolId(registerParameter.getThreadPoolId())
.corePoolSize(registerParameter.getCorePoolSize()) .corePoolSize(registerParameter.getCorePoolSize())
.maxPoolNum(registerParameter.getMaximumPoolSize()) .maximumPoolSize(registerParameter.getMaximumPoolSize())
.workQueue(BlockingQueueTypeEnum.createBlockingQueue(registerParameter.getBlockingQueueType().getType(), registerParameter.getCapacity())) .workQueue(BlockingQueueTypeEnum.createBlockingQueue(registerParameter.getBlockingQueueType().getType(), registerParameter.getCapacity()))
.threadFactory(registerParameter.getThreadNamePrefix()) .threadFactory(registerParameter.getThreadNamePrefix())
.threadFactory(registerParameter.getThreadFactory()) .threadFactory(registerParameter.getThreadFactory())

@ -43,7 +43,7 @@ public class DynamicThreadPoolSubscribeConfig {
private final ExecutorService configRefreshExecutorService = ThreadPoolBuilder.builder() private final ExecutorService configRefreshExecutorService = ThreadPoolBuilder.builder()
.corePoolSize(1) .corePoolSize(1)
.maxPoolNum(2) .maximumPoolSize(2)
.keepAliveTime(2000) .keepAliveTime(2000)
.timeUnit(TimeUnit.MILLISECONDS) .timeUnit(TimeUnit.MILLISECONDS)
.workQueue(BlockingQueueTypeEnum.SYNCHRONOUS_QUEUE) .workQueue(BlockingQueueTypeEnum.SYNCHRONOUS_QUEUE)

Loading…
Cancel
Save