1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-11-18 00:19:32 -08: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 fcb264d134
commit 40bdbd1948

View File

@ -124,6 +124,17 @@ public class AbacusController implements PluginListener {
* The alert shown when a press to "apply" is needed. * The alert shown when a press to "apply" is needed.
*/ */
private Alert reloadAlert; 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. * The runnable used to perform the calculation.
*/ */
@ -239,6 +250,7 @@ public class AbacusController implements PluginListener {
stopButton.setDisable(false); stopButton.setDisable(false);
calculationThread = new Thread(CALCULATION_RUNNABLE); calculationThread = new Thread(CALCULATION_RUNNABLE);
calculationThread.start(); calculationThread.start();
new Thread(TIMER_RUNNABLE).start();
} }
@FXML @FXML