如果是需要频繁调用,不建议使用此方案的多线程,建议使用线程池,可以重复调用
public Maptow() throws InterruptedException { Map map = new HashMap<>(); ExecutorService executorService = Executors.newFixedThreadPool(2);//做2个线程 executorService.submit(() -> { map.put("a", this.baseMapper.selectList(null));//操作1 }); executorService.submit(() -> { map.put("b", this.baseMapper.selectList(null));//操作2 }); executorService.shutdown(); executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MINUTES);//设置等待时间最大(即为不设置) return map; }



