Only restore interrupted state if necessary

This commit is contained in:
Alex Herbert 2021-08-20 21:19:23 +01:00 committed by Gilles Sadowski
parent 26e4a737f7
commit 75c7377e47
1 changed files with 4 additions and 2 deletions

View File

@ -124,8 +124,10 @@ public final class TravellingSalesmanSolver {
f.get();
}
} catch (InterruptedException | ExecutionException e) {
// Restore interrupted state...
Thread.currentThread().interrupt();
if (e instanceof InterruptedException) {
// Restore interrupted state...
Thread.currentThread().interrupt();
}
throw new RuntimeException(e);
}
// Terminate all threads.