线程池处理数据代码模板
public class Main {
public static void main(String[] args) {
ExecutorService executor = Executors.newFixedThreadPool(12);
String basePath = "";
File file = new File(basePath);
for (File file : file.listFiles()) {
try {
executor.execute(new Thread(() -> {
System.out.println(Thread.currentThread().getName() + "正在执行:" + file.getName());
));
//TODO 预热 放后面比前面管用
Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}