【发布时间】:2015-08-27 12:30:01
【问题描述】:
我在一个普通的私有函数中有以下代码 sn-p,它是从同一类中的另一个方法调用的(该类称为AdministrationComponent 其中extends CustomComponent)。该组件被添加到TabBarView。我的问题是,你在代码中看到的三个标签没有更新。
new Thread(new Runnable()
{
@Override
public void run()
{
while (true)
{
try
{
Thread.sleep(2000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
Runnable uiRunnable = () -> {
DSCXPSStatusInformation dsi = xpsService.getDSCXPSStatusInformation();
totalSpaceLabel.setValue(String.valueOf(dsi.getTotalSpaceInMB()) + " MB");
spaceLeftLabel.setValue(String.valueOf(dscxpsStatusInformation.getLeftSpaceInMB()) + " MB");
uptimeLabel.setValue(String.valueOf(dscxpsStatusInformation.getUptimeInSec()) + " sec");
};
UI.getCurrent().access(uiRunnable);
UI.getCurrent().push();
}
}
}).start();
【问题讨论】:
标签: java multithreading user-interface vaadin