Skip to content

Commit

Permalink
Update Solver.java
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 7, 2024
1 parent 9d4320b commit 6981029
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/main/java/de/nqueensfaf/Solver.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ public abstract class Solver {
private int solutionsSmallN = 0;
private boolean isSaving = false;
private final Thread shutdownHook = new Thread(() -> {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
while (isSaving) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
System.err.println("could not wait for auto save to finish: " + e.getMessage());
break;
try {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
while (isSaving) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
System.err.println("could not wait for auto save to finish: " + e.getMessage());
break;
}
}
}
}));
}));
} catch (IllegalStateException e) {
System.err.println("could not register shutdown hook for completing auto save: " + e.getMessage());
}
});

public abstract long getDuration();
Expand Down

0 comments on commit 6981029

Please sign in to comment.