2013-02-13 122 views
2

如何在不中断与任务进度相关的progressIndicator的情况下检查javafx后台任务是否完成。完成监控javafx任务

try 
{ 
AddMeteorParents amp = new AddMeteorParents(textOpenDB.getText(), textMeteorData.getText(), DatabaseTools.meteorVersion.Meteor14); 
proIndAddData.setVisible(true); 
proIndAddData.progressProperty().bind(amp.progressProperty()); 
Thread th = new Thread(amp); 
th.setDaemon(true); 
th.start(); 
} 

AddMeteorParents类从Task中扩展。 ProIndAddData是一个javafx进度指示器。如果我添加th.join()或th.isAlive()javafx progressIndicator停止工作?我想在任务完成时显示一条消息。

+0

我需要在任务1完成时运行第二个后台任务。如果不中断progressIndicator,我无法做到这一点。 – lochi 2013-02-13 18:33:43

回答

1

我能够使用的ExecutorService跑了一个又一个回地面任务(没有任何中断progressIndicators)。

ExecutorService eservice = Executors.newFixedThreadPool(1); 
+1

我创建了一些[示例代码](https://gist.github.com/jewelsea/4947946),它说明了这种方法。 – jewelsea 2013-02-13 20:31:16