我运行了一个更新应用程序打开时间的线程。它工作得很好。我已经扩大了服务范围。此任务的时间将更新我的GUI textField by Platform.runLater
@Override
protected Task<Void> createTask() {
return new Task<Void>() {
@Override
protected Void call() throws Exception {
while (!isCancelled()) {
if (isPause == false) {
try {
Platform.runLater(() -> {
currentTimeInApp = currentTimeInApp + 1;
upPanelController.timeInApp.setText
(currentTimeInApp.toString());
}
});
Thread.sleep(1000);
} catch (InterruptedException e) {
System.out.println(e.getMessage());
}
if (isCancelled())
break;
}
}
return null;
}
};
}
我想运行第二个线程,也更新图形用户界面。我不能运行相同的线程。两个独立的线程可以更新GUI吗?
互联网上的大部分信息都集中在一个主题上。谢谢你的每一个建议