先上代码
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
Properties config=new Properties();//记录配置项
try {
config.load(new FileInputStream("integrate.properties"));
config.setProperty("password",text_5.getText());
FileOutputStream  outputFile = new FileOutputStream("integrate.properties");
        config.store(outputFile, "test");
        outputFile.close();
} catch (Exception e1) {
// TODO 自动生成 catch 块
e1.printStackTrace();

Display.getCurrent().asyncExec(new Runnable(){ public void run() {
SqlFileExecutor sfe=new SqlFileExecutor(text_2);
try {
sfe.execute("data.sql");
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}

}

});

}
问题描述:
此代码是想要在一个shell里的一个按钮添加事件响应,当触发的时候,开启一个新的线程执行数据库建表脚本,表很多,所以要在每成功创建一个表后在该shell的一个text上打印xx表创建成功,
这段代码可以运行,但是在触发事件后,也就是建表,同时text打印信息的时候,只要一点这个界面,这个界面就卡死在那里了,只有等到线程执行完毕后才能恢复,大虾们来帮忙啊,谢