The Java Virtual Machine (JVM) services your application using two threads which you should be aware of, because blocking these threads for more than a fraction of a second can seriously harm your application’s performance. These threads are the Event Dispatch Thread (EDT, “Event Thread”, “User Interface/UI thread”), and the Application Management System (AMS) Thread.
The most commonly used system thread is
the Event Dispatch Thread (EDT), also referred to as the “event thread”.
This is the thread which repaints your desktop, and also provides
event notifications such as pointerPressed()
and keyPressed()
events.
The Series 40 phone also has a
second system thread, the Application Management System (AMS) thread.
This mostly lurks in the background doing maintenance tasks, but it
is visible to the user when the application lifecycle state changes: MIDlet.startApp()
,MIDlet.pauseApp()
and MIDlet.destroyApp()
.
Note that this thread is not
the same as the EDT for safety reasons: your application must be able
to close or receive a telephone call even if the EDT is not responsive.
It is also important to know that this thread may be
re-used by the Series 40 phone to complete other tasks, so to keep
your application starting quickly you must release the AMS thread
as soon as possible. You must of course complete necessary work before
releasing the AMS thread; for example, set current and paint the initial
screen of your application before releasing the AMS in a call to startApp()
to avoid unpleasant screen flashing or other
side effects.