方法一:CompletableFuture
CompletableFuture<List<UserDO>> userListFuture = CompletableFuture.supplyAsync(()->
userMapper.selectByIds(ids));
方法二:注解Async
@Async
https://www.cnblogs.com/jpfss/p/10273129.html
方法三:线程池
创建全局线程池,把要执行的任务放到线程池中执行。
this.defaultExecutor = new ThreadPoolExecutor(Runtime.getRuntime().availableProcessors() + 1,
Runtime.getRuntime().availableProcessors() + 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(1000));