J2ME Tips, Tricks and Oddities

This page wants to encourage interested fellows to share experiences and knowledge about J2ME. Whenever you find reusable thoughts, please post them here.

Oddities

Threading Problems

Communication Thread

There seems to be a designated thread that is in charge for things like getDisplay(), set commandAction() and other communication specific tasks. If a method of that sort leads to a loop, this thread gets blocked and wont do its other tasks any more.

Example:

public void commandAction(Command arg0, Displayable arg1) {
   if(arg0==exitCommand) parent.exitApplication();
   if(arg0==startCommand) neverReturningMethod();
}
public neverReturningMethod(){
   Display display = Display.getDisplay(theMainApplication);
   while(waitForCommand){
      /* do something */
   }
}
In this case it is very likely that the thread will never manage to set the current display, in particular the graphics, as it is occupied with other stuff.

-- MarcBreisinger - 31 Aug 2006
Topic revision: r2 - 16 May 2007, RainerFink
 
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Medieninformatik-Wiki? Send feedback