JavaFX SwingWorker Equivalent?

后端 未结 3 1345
隐瞒了意图╮
隐瞒了意图╮ 2020-12-06 11:31

Is there a JavaFX equivalent to the Java SwingWorker class?

I am aware of the JavaFX Task but with that you can only publish String messages or a progress. I just wa

3条回答
  •  眼角桃花
    2020-12-06 12:03

    Don't ever use SwingWorker. This piece of code in the SwingWorker.java source should be enough of an argument to not use it:

    private static final int MAX_WORKER_THREADS = 10;
    

    Instead get yourself familiar with Executor and the services that come along with it.

    It has nothing to do with JavaFX, it's just plain Java. However, your question was related to JavaFX. Here's an example about how to Update UI in JavaFX Application Thread using Platform.runLater().

提交回复
热议问题