部分bug

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();
            }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值