How to stop the Task<v></v>
-
How do we stop this flow?
Task<Void> task = new Task<Void>(){ @Override protected Void call() throws Exception { double TimeStart = 0d; for (int row = 0; row < 100; row++) { TimeStart = TimeStart + 0.01; updateProgress(TimeStart, 1); try { Thread.sleep(normalTime); } catch (InterruptedException e) { } } return null; } }; time.progressProperty().bind(task.progressProperty()); Executors.newCachedThreadPool().submit(task);
-
Used https://docs.oracle.com/javase/8/docs/api/java/util/Timer.html#cancel--%28%29 Method:
task.cancel(true);
♪
Task
Please add the exemptions in the processor:Task<Void> task = new Task<Void>(){ @Override protected Void call() throws Exception { double TimeStart = 0d; for (int row = 0; row < 100; row++) { TimeStart = TimeStart + 0.01; updateProgress(TimeStart, 1); try { Thread.sleep(normalTime); } catch (InterruptedException e) { return null; } } return null; } };