Skip to main content

just need some advice on threading issue in LWUIT

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
2 replies [Last post]
obinnahenree
Offline
Joined: 2007-03-08
Points: 0

hi, i am using LWUIT 1.5 for an application. typically i show a form with a wait message, make http connection in a different thread and show a new form after the response.

I just want to know if the way i am doing this is OKAY.

//sample actionPerformed

public void actionPerformed(....){

waitForm.show(); // a form with a single label (loading..please wait.)

LongRunnable lr = new LongRunable(); Thread t = new Thread(lr); t.start();

}

//then in the runnable's run method

public void run(){

//do all http connection stuff and process the response

someOtherForm.show();

}

Is this style okay, or is there a place i could replace with callSerially(..). Any Suggestions is okay.

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mzorz
Offline
Joined: 2008-04-28
Points: 0

You should perform any call to LWUIT .show() within a callSerially call. It's ok if you are in within actionPerformed because you are already into the EDT, but otherwise what you should do is this:

// in the runnable's run method

public void run(){

//do all http connection stuff and process the response

                        Display.getInstance().callSerially(new Runnable() {
                               public void run() {

                                      someOtherForm.show();
                               }
                            }
                        );
}

BR

Mario

obinnahenree
Offline
Joined: 2007-03-08
Points: 0

thanks mario, appreciate ur response.