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

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

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

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

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

Loading…
Cancel
Save