multithreading - Lwiit J2ME 中的等待屏幕

标签 multithreading java-me loading lwuit

我只想在我的 Lwiit J2ME 应用程序中解析一些 Xml 时显示加载屏幕。
我看到有很多例子,例如 slider 和仪表,我找到了这个简单的代码,但我不知道如何在解析操作时显示对话框。
如果我使用 dialog.showDialog();它会阻止用户界面

passenger p = new passenger();
p.start();
synchronized (p) {
System.out.println("passenger is waiting for the bus ");    

        try {
            p.wait();
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
                    System.out.println("passenger  got notification");
                    // I think that i must use the loading thing here but i don't know    
                    // what to do.

            }
            System.out.println("after "+p.total+" time");






    class passenger  extends Thread {
    int total = 0;

    public void run() {
            synchronized (this) { 

                    System.out.println("wait .... ");
                    for (int i = 0; i <= 3000; i++){
                            total = total + i;
                            System.out.println(total+"");
                    }
                    System.out.println("passenger  is given  notification call");
                    notify();
            }
    }

最佳答案

您需要在后台线程中进行解析,然后在完成后处理对话框。

关于multithreading - Lwiit J2ME 中的等待屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12253441/

相关文章:

java - 方法是否需要同步?

blackberry - 黑莓上的应用程序详细信息

java-me - 用于确定 J2ME 的 JSR 实现范围的资源

android - 有没有办法将 Activity 加载到屏幕的特定部分?

java - Hibernate 启用 PostLoad 事件

c# - C#Winforms System.Threading.Timer

java - 使用线程

Java 蓝牙远程设备列表

javascript - 加载 javascript、EnhanceJS

c++ - 关闭在线程上运行的 GStreamer RTSP 服务器