You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.5 KiB
Java
57 lines
1.5 KiB
Java
package com.glxp.mipsdl.util;
|
|
|
|
import cn.hutool.core.thread.ExecutorBuilder;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.LinkedBlockingDeque;
|
|
|
|
/**
|
|
* java线程池
|
|
*/
|
|
@Slf4j
|
|
@Component
|
|
public class ExecutorUtil {
|
|
|
|
/**
|
|
* 日志记录线程池
|
|
*/
|
|
private ExecutorService log_executor;
|
|
|
|
/**
|
|
* 上传文件解析数据到UDI管理系统线程池
|
|
*/
|
|
private ExecutorService upload_executor;
|
|
|
|
@PostConstruct
|
|
public ExecutorService getLogExecutor() {
|
|
if (null == log_executor) {
|
|
log.info("创建日志线程池");
|
|
log_executor = ExecutorBuilder.create()
|
|
.setCorePoolSize(10)
|
|
.setMaxPoolSize(500)
|
|
.setWorkQueue(new LinkedBlockingDeque<>())
|
|
.build();
|
|
log.info("日志线程池创建完成");
|
|
return log_executor;
|
|
}
|
|
return log_executor;
|
|
}
|
|
|
|
@PostConstruct
|
|
public ExecutorService getUploadExecutor() {
|
|
if (null == upload_executor) {
|
|
log.info("创建回传数据线程池");
|
|
upload_executor = ExecutorBuilder.create()
|
|
.setCorePoolSize(10)
|
|
.setMaxPoolSize(200)
|
|
.setWorkQueue(new LinkedBlockingDeque<>())
|
|
.build();
|
|
}
|
|
return upload_executor;
|
|
}
|
|
|
|
}
|