1

I just want to show a loading screen while parsing some Xml in my Lwuit J2ME Application. I saw that there are many examples such as the slider and the gauge,and i found this simple code but i don't know how to show the dialog while the parsing operation. If i used dialog.showDialog(); it will block the UI

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();
            }
    }
tshepang
  • 12,111
  • 21
  • 91
  • 136
Reham
  • 1,916
  • 6
  • 21
  • 45

1 Answers1

3

You need to do your parsing in a background thread and then dispose the dialog when you are done.

Shai Almog
  • 51,749
  • 5
  • 35
  • 65
  • thank you,can you tell me if i can use any of the above code to help me do that.Or there is another way to implement the Waiting Screen? – Reham Sep 07 '12 at 19:21
  • You are invoking wait() on the EDT which sort of negates the idea of opening a new thread. You need to release the EDT after showing the wait dialog. – Shai Almog Sep 20 '12 at 06:02