您可以使用来将其范围缩小到更合理的线程数
ExecutorService。您可能想要使用接近可用处理器核心数量的一些东西,例如:
int threads = Runtime.getRuntime().availableProcessors();ExecutorService service = Executors.newFixedThreadPool(threads);for (int i = 0; i < 36; i++) { service.execute(new Runnable() { public void run() { // do what you need per file here } });}service.shutdown();


