【发布时间】:2015-05-02 16:25:35
【问题描述】:
当我关闭应用程序时,下面的代码没有正确退出。我相信问题是我在哪里准确调用 system.exit 和 platform.exit....
hour_Label.textProperty().bind(hour);
minute_Label.textProperty().bind(minute);
second_Label.textProperty().bind(second);
new Thread(() ->
{
for (;;)
{
try
{
final SimpleDateFormat simpledate_hour = new SimpleDateFormat("h");
final SimpleDateFormat simpledate_minute = new SimpleDateFormat("mm");
final SimpleDateFormat simpledate_second = new SimpleDateFormat("s");
Platform.runLater(new Runnable() {
@Override public void run()
{
hour.set(simpledate_hour.format(new Date()));
minute.set(simpledate_minute.format(new Date()));
second.set(simpledate_second.format(new Date()));
}
});
Thread.sleep(200);
}
catch (Exception e){logger.warn("Unexpected error", e); Thread.currentThread().interrupt(); Platform.exit(); System.exit(0);}
}
}).start();
【问题讨论】:
-
“没有正确退出”是什么意思?
-
当我关闭它时,我必须强制退出 OS X 上的应用程序
标签: java multithreading javafx exit platform