multithreading - JavaFx and Concurrency -


i've got following code:

the controller.class of project:

    private task<observablelist<payment>> allentrietask= new task<observablelist<payment>>(){         @suppresswarnings("unchecked")         @override         protected observablelist<payment> call() throws exception {             list<payment> list = (list<payment>) sqlexecutor.listallentries(payment.class);             observablelist<payment> payments = (observablelist<payment>) fxcollections.observablelist(list);             fxcollections.sort(payments);             return payments;         }      };      private task<observablelist<payment>> revenueentrietask= new task<observablelist<payment>>(){         @suppresswarnings("unchecked")         @override         protected observablelist<payment> call() throws exception {             list<payment> list = (list<payment>) sqlexecutor.listentries(payment.class, restrictions.gt("payment", 0.0));             observablelist<payment> payments = fxcollections.observablelist(list);             fxcollections.sort(payments);             return payments;         }      };      private task<observablelist<payment>> outputsentrietask= new task<observablelist<payment>>(){         @suppresswarnings("unchecked")         @override         protected observablelist<payment> call() throws exception {             list<payment> list = (list<payment>) sqlexecutor.listentries(payment.class, restrictions.lt("payment", 0.0));             observablelist<payment> payments = fxcollections.observablelist(list);             fxcollections.sort(payments);             return payments;         }      }; public void ontreeaction(mouseevent e){         if(e.getclickcount() == 2){             string chosenitem = tree.getselectionmodel().getselecteditem().getvalue(); //ausgewähltes item             if(chosenitem.equals("alle zahlungen")){                 listallpayments();                 actualtable = "alle zahlungen";             }else if(chosenitem.equals("einzahlungen")){                 listallrevenues();                 actualtable = "einzahlungen";             }else if(chosenitem.equals("auszahlungen")){                 listalloutputs();                 actualtable = "auszahlungen";             }         }     }      private void listallpayments(){         thread t = new thread(allentrietask);         t.setdaemon(true);         t.start();         allentrietask.setonsucceeded(event -> table.setitems(allentrietask.getvalue()));     }      private void listallrevenues(){         thread t = new thread(revenueentrietask);         t.setdaemon(true);         t.start();         revenueentrietask.setonsucceeded(event -> table.setitems(revenueentrietask.getvalue()));     }      private void listalloutputs(){         thread t = new thread(outputsentrietask);         t.setdaemon(true);         t.start();         outputsentrietask.setonsucceeded(event -> table.setitems(outputsentrietask.getvalue()));     } 

is way how should when use concurrency in java?i've putted ,all code may need time act, inside task starts when specified item selected in treeview. question i've got,i got code:

   private void listallpayments(){     thread t = new thread(allentrietask);     t.setdaemon(true);     t.start();     allentrietask.setonsucceeded(event -> table.setitems(allentrietask.getvalue())); } 

this action: allentrietask.setonsucceeded(event -> table.setitems(allentrietask.getvalue())); running on fxapplicationthread right?or must somegthing platform.runlater(//do stuff). project works fine wihtout error or info


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -