我想在我的 Eclipse RAP 应用程序的后台执行查询,但不会阻塞 UI。我遵循了本指南:http ://eclipse.org/rap/developers-guide/devguide.php?topic=threads.html&version=2.2
但没有成功:/
查询已执行,但在调用时它总是阻塞 UI。这是我正在使用的代码:
final ServerPushSession pushSession = new ServerPushSession();
Runnable bgRunnable = new Runnable() {
public void run() {
// schedule the UI update
display.syncExec( new Runnable() {
public void run() {
try {
//CODE
try {
Thread.sleep(5000);
}
catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
catch (PartInitException e) {
e.printStackTrace();
System.exit(0);
}
setText( "updated" );
}
} );
// close push session when finished
pushSession.stop();
}
};
pushSession.start();
Thread bgThread = new Thread( bgRunnable );
bgThread.setDaemon( true );
bgThread.start();
有人知道发生了什么吗?