fix: only set capacity, capacity is invalid. (#570)

pull/575/head
BigXin0109 2 years ago committed by GitHub
parent d7514ff759
commit 63fc5a8a16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,9 +47,9 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
private int capacity = 512;
private BlockingQueueTypeEnum blockingQueueType;
private BlockingQueueTypeEnum blockingQueueType = BlockingQueueTypeEnum.LINKED_BLOCKING_QUEUE;
private BlockingQueue workQueue = new LinkedBlockingQueue(capacity);
private BlockingQueue workQueue;
private RejectedExecutionHandler rejectedExecutionHandler = new ThreadPoolExecutor.AbortPolicy();
@ -246,7 +246,10 @@ public class ThreadPoolBuilder implements Builder<ThreadPoolExecutor> {
initParam.setAwaitTerminationMillis(builder.awaitTerminationMillis);
}
if (!builder.isFastPool) {
if (builder.blockingQueueType != null) {
if (builder.workQueue == null) {
if (builder.blockingQueueType == null) {
builder.blockingQueueType = BlockingQueueTypeEnum.LINKED_BLOCKING_QUEUE;
}
builder.workQueue = BlockingQueueTypeEnum.createBlockingQueue(builder.blockingQueueType.getType(), builder.capacity);
}
initParam.setWorkQueue(builder.workQueue);

Loading…
Cancel
Save