Hello,
I'm trying to use the Task and Service classes to do multithreading treatment on my javafx application. But im quite confused about it.
Here are the steps i want to follow :
1) I click on one of my IHM button.
2) the click handler launch a parallel thread (Task) which execute complex and long treatment. In the meantime the javafx thread is terminating and the gui is released.
3) When the calculation are finished on the parallel thread, it change the children on one of my ihm hbox.
Here the code i made.
click_handler :
[CODE]
HBox hboxResultat = (HBox) vboxListInput .getChildren().get(indexHbox);
Task<HBox> taskProcessWord = new Task<HBox>() {
@Override protected HBox call() throws Exception {
try {
//Long and complex calculation.
} catch (Exception e) {
log.error(e);
}
//reinit hbox
HBox myHbox = new HBox();
//add nodes to hbox
addInfosToHbox(myHbox);
return myHbox;
}
};
hboxResultat = taskProcessWord.valueProperty().get();
Thread th = new Thread(taskProcessWord);
th.setDaemon(true);
System.out.println("Starting background task...");
th.start();
[/CODE]
the code above doesn't produce any result. Can u help me?