java - Control Task with another Task in JavaFX -


here's i'm trying do: task 1 runs , @ same time executes task 2, task 2 has method runs every 15 seconds (for use timer class), method stops task 1 , after finishing resumes task 1. problem when try call task 1 in task 2 , execute .isrunning() or .wait() following error appears "task must used fx application thread". dont understand if error appearing because i'm using timer class running task 2 or because cant reference task withint task. here code task 2:

public void unfollowusers(timer t, task<void> likestask, webdriver driver) throws interruptedexception {         if (!userstounfollow.isempty() && likestask.isrunning()) {             likestask.wait();             //some code             likestask.notify();         } else if (!userstounfollow.isempty()) {             //some code         } else {             t.cancel();         }     }      public task<void> unfollowstask(task<void> likestask, webdriver driver) throws interruptedexception {         textarea logbox = guicontroller.getlogbox();         return new task<void>() {             @override             public void call() throws interruptedexception, failinghttpstatuscodeexception, ioexception {                 timer t = new timer();                 t.schedule(new timertask() {                     @override                     public void run() {                         try {                             unfollowusers(t, likestask, driver);                         } catch (interruptedexception ex) {                             system.out.println(ex);                         }                     }                 }, 0, 15000);                 return null;             }         };     }      public void startunfollowsthread(task<void> likestask, webdriver driver) throws interruptedexception {         textarea logbox = guicontroller.getlogbox();         task<void> unfollowstask = unfollowstask(likestask, driver);          unfollowstask.setonsucceeded((workerstateevent t) -> {             utils.addlogline(logbox, "[+] unfollows terminados!");             unfollowstask.cancel();         });          new thread(unfollowstask).start();     } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -