1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-06-23 11:17:06 -07:00

Add a timer to the computation thread to stop it from running.

This commit is contained in:
Danila Fedorin 2017-08-07 08:58:47 -07:00
parent 6a15c266c4
commit 7ae7f6d9a5

View File

@ -124,6 +124,17 @@ public class AbacusController implements PluginListener {
* The alert shown when a press to "apply" is needed.
*/
private Alert reloadAlert;
/**
* The runnable that takes care of killing computations that take too long.
*/
private final Runnable TIMER_RUNNABLE = () -> {
try {
Thread.sleep(30 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
performStop();
};
/**
* The runnable used to perform the calculation.
*/
@ -239,6 +250,7 @@ public class AbacusController implements PluginListener {
stopButton.setDisable(false);
calculationThread = new Thread(CALCULATION_RUNNABLE);
calculationThread.start();
new Thread(TIMER_RUNNABLE).start();
}
@FXML