/**
* Optimization - Reuse the the threads.
*/
executorPool = Executors.newCachedThreadPool();
for (String file : files) {
Callable
fileList.add(reader);
}
List
/**
* Check how many success and how many failure
*/
int success = 0, failure = 0;
for (Future
if (result.get() == null) {
failure++;
} else {
success++;
}
System.out.println("Total number of files [" + fileList.size() + "]");
System.out.println("Success Count [" + success + "]");
System.out.println("Failure Count [" + failure + "]");
} else {www.2cto.com
throw new IllegalArgumentException("There is no such directory name -" + directory);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (executorPool != null) {
executorPool.shutdown();
}
}
}
}
作者:沉默是金