【发布时间】:2013-12-28 04:03:37
【问题描述】:
我的 FXML 应用程序中有 Label label。
我希望此标签每秒更改一次。目前我使用这个:
Task task = new Task<Void>() {
@Override
public Void call() throws Exception {
int i = 0;
while (true) {
lbl_tokenValid.setText(""+i);
i++;
Thread.sleep(1000);
}
}
};
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
但是什么都没有发生。
我没有收到任何错误或异常。
我不需要在我的主 GUI 线程中将标签更改为的值,所以我看不到 updateMessage 或 updateProgress 方法中的要点。
怎么了?
【问题讨论】:
标签: java multithreading javafx-2 task