|
|
|
@ -1,8 +1,9 @@
|
|
|
|
|
package io.dynamic.threadpool.starter.adapter;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.thread.ThreadFactoryBuilder;
|
|
|
|
|
import io.dynamic.threadpool.common.config.ApplicationContextHolder;
|
|
|
|
|
import io.dynamic.threadpool.common.enums.QueueTypeEnum;
|
|
|
|
|
import io.dynamic.threadpool.starter.operation.ThreadPoolOperation;
|
|
|
|
|
import io.dynamic.threadpool.starter.toolkit.thread.ThreadPoolBuilder;
|
|
|
|
|
import io.dynamic.threadpool.starter.wrap.DynamicThreadPoolWrap;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.core.annotation.Order;
|
|
|
|
@ -11,7 +12,6 @@ import javax.annotation.PostConstruct;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.ArrayBlockingQueue;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
@ -27,14 +27,13 @@ public class ThreadPoolConfigAdapter extends ConfigAdapter {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ThreadPoolOperation threadPoolOperation;
|
|
|
|
|
|
|
|
|
|
private ExecutorService executorService = new ThreadPoolExecutor(
|
|
|
|
|
2,
|
|
|
|
|
4,
|
|
|
|
|
0,
|
|
|
|
|
TimeUnit.MILLISECONDS,
|
|
|
|
|
new ArrayBlockingQueue(1),
|
|
|
|
|
new ThreadFactoryBuilder().setNamePrefix("threadPool-config").build(),
|
|
|
|
|
new ThreadPoolExecutor.DiscardOldestPolicy());
|
|
|
|
|
private ExecutorService executorService = ThreadPoolBuilder.builder()
|
|
|
|
|
.poolThreadNum(2, 4)
|
|
|
|
|
.keepAliveTime(0L, TimeUnit.MILLISECONDS)
|
|
|
|
|
.workQueue(QueueTypeEnum.ARRAY_BLOCKING_QUEUE, 1)
|
|
|
|
|
.threadFactory("threadPool-config")
|
|
|
|
|
.rejected(new ThreadPoolExecutor.DiscardOldestPolicy())
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
@Order(1025)
|
|
|
|
|
@PostConstruct
|
|
|
|
|