我有一个 JFrame 子类,它管理我的 UI 并调用 Item 对象的方法来导入数据库中的项目:
public TestGUI() throws IOException
{
initComponents();
Item.importItems(progressBar); // static method that execute a new thread to import item witouth freeze my UI (I update a progressBar in it)
table.refresh(); //Metodh that I need to execute only after "importItems()" methods is completed
}
Item对象实现Runnable以在新Thread中执行导入操作
public Item implements Runnable
{
private JProgressBar progressBar;
public void importItems (JProgressBar progressBar) throws IOException //Metodo per importare articoli da un file esterno. Usa i Thread.
{
this.progressBar = progressBar;
Thread importThread = new Thread (new RefreshTable(),"Importer Thread");
importThread.start();
}
void run ()
{
// I execute here all the DB operation that i need. I also update the progress bar here
}
}
我怎样才能修改该代码来执行table.refresh()
仅在之后Item.importImtes(progressBar)
结束其执行?谢谢!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)