//创建一个线程池,规定只能处理100个线程,但是我们会创建1000个线程,用来模拟多线程访问数据库 ExecutorService executorService = Executors.newFixedThreadPool(100); for (int i = 0; i < 1000; i++) { executorService.submit(new Runnable() { @Override public void run() { //获取平台历史年化收益率 Double historyAverageRate = lonInfeService.quaryhistoryAverageRate(); model.addAttribute(Constant.HISTORY_AVERAGE_RATE, historyAverageRate); } }); } executorService.shutdown();