Shutdown digester thread pool when done.

Closes #89.
This commit is contained in:
Michael Bayne
2017-12-11 10:09:31 -08:00
parent 0fd022d9cc
commit c26f5a2468
@@ -48,7 +48,8 @@ public class Digest
throws IOException throws IOException
{ {
// first compute the digests for all the resources in parallel // first compute the digests for all the resources in parallel
Executor exec = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); ExecutorService exec = Executors.newFixedThreadPool(
Runtime.getRuntime().availableProcessors());
final Map<Resource, String> digests = new ConcurrentHashMap<>(); final Map<Resource, String> digests = new ConcurrentHashMap<>();
final BlockingQueue<Object> completed = new LinkedBlockingQueue<>(); final BlockingQueue<Object> completed = new LinkedBlockingQueue<>();
final int fversion = version; final int fversion = version;
@@ -71,6 +72,9 @@ public class Digest
}); });
} }
// queue a shutdown of the thread pool when the tasks are done
exec.shutdown();
try { try {
while (pending.size() > 0) { while (pending.size() > 0) {
Object done = completed.poll(600, TimeUnit.SECONDS); Object done = completed.poll(600, TimeUnit.SECONDS);