rev:修改
This commit is contained in:
@@ -16,9 +16,12 @@
|
|||||||
package org.nl.config.thread;
|
package org.nl.config.thread;
|
||||||
|
|
||||||
|
|
||||||
|
import org.dromara.dynamictp.core.support.DynamicTp;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
@@ -32,14 +35,19 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class ThreadPoolExecutorUtil {
|
public class ThreadPoolExecutorUtil {
|
||||||
|
|
||||||
@Bean(name = "meshandlerPool")
|
@Autowired
|
||||||
public ThreadPoolExecutor meshandlerPool(){
|
private AsyncTaskProperties asyncTaskProperties;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Primary
|
||||||
|
@DynamicTp("el-thread")
|
||||||
|
public ThreadPoolExecutor threadPoolExecutor() {
|
||||||
return new ThreadPoolExecutor(
|
return new ThreadPoolExecutor(
|
||||||
4,
|
asyncTaskProperties.getCorePoolSize(),
|
||||||
16,
|
asyncTaskProperties.getMaxPoolSize(),
|
||||||
30,
|
asyncTaskProperties.getKeepAliveSeconds(),
|
||||||
TimeUnit.SECONDS,
|
TimeUnit.SECONDS,
|
||||||
new ArrayBlockingQueue<>(64),
|
new ArrayBlockingQueue<>(asyncTaskProperties.getQueueCapacity()),
|
||||||
new TheadFactoryName()
|
new TheadFactoryName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user