-3
我想再次顯示對話框,而我從Web服務 我使用LWUIT加載一些數據,多線程在J2ME和LWUIT
以下是代碼
public class LoaderAnimation extends Container implements Runnable {
private Thread t;
private boolean running = false;
public LoaderAnimation() {
}
public void start() {
running = true;
t = new Thread(this);
t.start();
}
public void run() {
while (running) {
// do something
t.sleep(150);
}
}
public void stop() {
running = false;
}
}
現在發生的事情,它運行,但調用Web服務的代碼中有停止工作
那就是它的調用
public static void showLoaderScreen()
{
dialog = new Dialog();
dialog.setLayout(new BorderLayout());
canvas = new LoaderAnimation();
dialog.addComponent(BorderLayout.CENTER , canvas);
canvas.start();
dialog.show();
}
public static void dismissLoaderScreen()
{
canvas.stop();
dialog.dispose();
}
並代碼段你貼編譯?據我所知,[t.sleep(150)](http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/java/lang/Thread.html#睡眠(long)「API javadocs」)會拋出'InterruptedException',但沒有捕獲 - 並且你肯定無法重新拋出,因爲它是'Runnable'。另外,你最好將運行聲明爲volatile – gnat 2012-04-29 14:45:32