1、Arrays.asList(alias)时不能删除数据
Arrays.asList(Convert.toIntArray(splitMonthDay)
2、spring boot上传文件错误The temporary upload location [/tmp/tomcat.******/work/Tomcat/localhost/ROOT] is no
注入bean
@Bean
MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setLocation("/tmp/tomcat");
return factory.createMultipartConfig();
}
3、线程
配置
package com.ecarxgroup.okr.business.config;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.concurrent.ThreadPoolExecutor;
/**
* @Author e-hanxiaoxu
* @create 2022/5/25 16:43
*/
public class BusiThreadPoolExecutor {
private static ThreadPoolTaskExecutor executor;
private static final Integer CORE_POOL_SIZE = 5;
private static final Integer MAX_POOL_SIZE = 5;
private static final Integer QUEUE_CAPACITY = 1000;
private static final Integer KEEP_ALIVE_SECONDS = 300;
private BusiThreadPoolExecutor() {
}
/**
* 无返回值执行方法
*
* @param task
*/
public static void execute(Runnable task) {
checkExecutor();
if (task != null) {
executor.execute(task);
}
}
private static void checkExecutor() {
// 如果线程池为空或者线程池已经关闭,需要新建线程池
if (executor == null) {
//使用双重判定,保证线程安全
synchronized (BusiThreadPoolExecutor.class) {
if (executor == null) {
// 默认为定长线程池
//executor = Executors.newCachedThreadPool();
executor = new ThreadPoolTaskExecutor();
executor.initialize();
//配置核心线程数
executor.setCorePoolSize(CORE_POOL_SIZE);
//配置最大线程数
executor.setMaxPoolSize(MAX_POOL_SIZE);
//配置队列大小
executor.setQueueCapacity(QUEUE_CAPACITY);
//配置空闲时间
executor.setKeepAliveSeconds(KEEP_ALIVE_SECONDS);
//线程前缀名称
executor.setThreadNamePrefix("mas-");
//配置拒绝策略
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
}
}
}
}
}
使用:
CountDownLatch countDownLatch = new CountDownLatch(lists.size());
try {
for (List<UserVO> list: lists) {
XXXXPoolExecutor.execute(new Runnable() {
@Override
public void run() {
try {
XXXXXX
}
} finally {
countDownLatch.countDown();
}
}
});
}
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
}