推荐:》》》
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(5, 10, 5, TimeUnit.SECONDS, new ArrayBlockingQueue(2), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy()); for (int i = 0; i < 6; i++) { try { threadPoolExecutor.execute(()->{ order.setOrderType(101); order.setCustomerId(100); order.setAmount(new BigDecimal(100100)); int mies = userService.insertOrder(order); }); return 1; } catch (Exception e) { e.printStackTrace(); } finally { threadPoolExecutor.shutdown(); } }