I'm really stumped on how to create separate threads in JavaFX. I've tried everything I've found on the internet including using a java class that extends runnable and using EventQueue.invokeLater(). This just stops the JavaFX thread while running the Java code in invokeLater()
JavaFX 1.2 has included java.async.Task, but I have no idea how to use this, there are no resources on the internet.
At the moment, I'm calling RMI on a java servlet, and the GUI freezes while the methods wait for a return type.
import javafx.async.Task;
import javafx.async.RunnableFuture;
import com.sun.javafx.runtime.async.AsyncOperationListener;
import java.lang.Exception;
publicclass JavaFXTaskBase extends Task {
var peer: AsyncProgramMoveImpl;
public var action:function();
public override function start() : Void{
if (peer == null) {
peer = new AsyncProgramMoveImpl(RunnableFuture{ override function run(){ action() } }, asyncListener );
peer.start();
}
}
public override function stop() : Void{
}
var asyncListener = AsyncOperationListener {
public override function onProgress(progressValue:Integer, progressMax:Integer):Void {}
public override function onCompletion(value:Object):Void {}
public override function onCancel():Void {}
public override function onException(e:Exception):Void{}
}
}
нет смысла. Там ничего интересного. Если в целях самообразования то придётся ждать когда я протестю всё по версию 1.2. Отдельные куски я публиковать не буду.
Can/will the new thread still block/deadlock the gui thread? Or do new JAVA threads need to be created/forked off a RunnableFuture/Task? I've got deadlock, I can see how JavaFX thread/async works - but where JAVA threads belong isn't clear. We have a lot of daemon threaded Java code, I don't want to (and can't) re-write everything to be based on JavaFX's Async.