aspose file tools
The moose likes Java Micro Edition and the fly likes display thread Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Reply Bookmark "display thread" Watch "display thread" New topic
Author

display thread

Stephen Cole
Greenhorn

Joined: Nov 16, 2001
Posts: 3
My testing seems to show that the initial thread that is created in the vm and executes the commandAction callback must return before the display can be changed. Therefore it is not possible to change the screen within this thread and see that screen change until the thread returns to the vm. This seems to be the case on the wireless toolkit emulators, the motorola emulator and the i85s phone. Is this accurate?
Does anyone have any experience putting up a busy wait screen while a long running network operation is taking place? I would like to have the different parts of the application make a serial call to a communications piece that could put up a busy wait screen while it waited for the query response, bu this is not possible if you just use the main thread. So the alternative seems to be to use another thread and thus be able to return the system thread which then allows the screen to be changed.
Does anyone know if this is a MIDP/J2ME spec thing or just a vendor implementation?
thanks
stephen cole
Eric Giguere
Ranch Hand

Joined: Oct 25, 2000
Posts: 170
This is normal and expected behavior. It's a common user interface model: one thread services the user interface and other threads do lengthy things like networking. In Swing on J2SE, for example, you have to do *everything* UI related on one particular thread. MIDP doesn't have that limitation, but yes, callbacks and such occur on a single thread and any changes you make to the display won't occur until you return from that thread and the system gets control. So design your apps accordingly -- do all the networking on a separate thread. If you look at the J2ME Tech Tips I write (see http://www.j2medeveloper.com) I have at least one tip that talks about this with examples.


Eric Giguere
Author/Co-Author of: Mobile Information Device Profile for Java 2 Micro Edition: Professional Developer's Guide, Java 2 Micro Edition: Professional Developer's Guide and PalmTM Database Programming: The Complete Developer's Guide
 
 
subject: display thread
 
Threads others viewed
Blocking
Will this locking mechanism be allowed?
dead-locking scenario
Http connections using background threads
JFrame not repainting when overlayed JDialog is closed
IntelliJ Java IDE