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(); f.get();
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
// Restore interrupted state... if (e instanceof InterruptedException) {
Thread.currentThread().interrupt(); // Restore interrupted state...
Thread.currentThread().interrupt();
}
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// Terminate all threads. // Terminate all threads.