Skip to content

Commit

Permalink
fix: only set capacity, capacity is invalid. (opengoofy#570)
Browse files Browse the repository at this point in the history
  • Loading branch information
BigXin0109 authored Aug 26, 2022
1 parent d7514ff commit 63fc5a8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -246,7 +246,10 @@ private static AbstractBuildThreadPoolTemplate.ThreadPoolInitParam buildInitPara
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);
Expand Down

0 comments on commit 63fc5a8

Please sign in to comment.