【发布时间】:2012-11-29 18:50:05
【问题描述】:
我正在处理现有代码,我在其中一个类中找到了这段代码。
该代码使用ExecutorService,而不是使用MyThread.start。
请告诉我为什么要使用ExecutorService 而不是Thread.start。
protected static ExecutorService executor = Executors.newFixedThreadPool(25);
while (!reader.isEOF()) {
String line = reader.readLine();
lineCount++;
if ((lineCount > 1) && (line != null)) {
MyThread t = new MyThread(line, lineCount);
executor.execute(t);
}
}
【问题讨论】:
标签: java multithreading executorservice