Previous Next |
MultithreadingMultiple threads are available within a Java virtual machine. Both the MIDP implementor and the app developer need to use these threads safely. Using threads safely means that shared data never becomes corrupted, even in the presence of concurrent access, and that the system is live (threads do not deadlock). Thread SafetyThe Java Tutorial: A Short Course on the Basics (Third version) [16], has information on how to properly protect shared information in the Java coding language. This section provides some MIDP-specific suggestions and requirements. apps must be allowed to define and implement their own locking policies for their own data structures, without any restrictions from LCDUI beyond those imposed by the MIDP 2.0 Specification [19]. apps should be free to use locks even on LCDUI objects, and to create subclasses of LCDUI classes without violating any safety guarantees. MIDP Implementors
app DevelopersIf your MIDlet is multithreaded, define and use a locking policy in your app that protects its shared data without deadlocking.
ResponsivenessIn addition to keeping their apps deadlock free and safe, app developers must also be concerned about responsiveness. (See "Make It Responsive" on page 10 for information.) Specifically, callbacks need to be responsive, and they can be most responsive when multiple threads are used appropriately. A callback is a method that an app developer writes and a device calls to perform a task at appropriate times. A MIDP implementation informs a MIDlet about user actions, such as selecting an abstract command, through callbacks, such as the commandAction method.
|
Previous Next |