Skip to content

Commit

Permalink
#kernel_base_12: switch interrupting mode to message
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslawmalekcodete committed Jul 31, 2020
1 parent ba296c3 commit afdb5bc
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,19 @@ public void exit() {
}

public void interruptKernel() {
try {
current.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
waitForTheEndOfTheCurrentCell();
List<Runnable> cells = executorService.shutdownNow();
cells.forEach(Runnable::run);
executorService = Executors.newFixedThreadPool(1);
}

private void waitForTheEndOfTheCurrentCell() {
if (current != null) {
try {
current.get();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

0 comments on commit afdb5bc

Please sign in to comment.