mirror of
				https://github.com/DanilaFe/abacus
				synced 2025-10-30 17:33:42 -07:00 
			
		
		
		
	Add a timer to the computation thread to stop it from running.
This commit is contained in:
		
							parent
							
								
									fcb264d134
								
							
						
					
					
						commit
						40bdbd1948
					
				| @ -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 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user