MIdlet's class javadoc states that MIdlet.destroyApp()
will be called if MIdlet.startApp()
throws a RuntimeException
. Assuming no exception is thrown while executing MIDlet.startApp()
.
Is MIDlet.startApp()
guaranteed to be executed fully before MIDlet.pauseApp()
or MIDlet.destroyApp()
is called ?
Example:
MIdlet's class implementation:
startApp()
{
System.out.println("A");
System.out.println("B");
}
pauseApp()
{
System.out.println("C");
System.out.println("D");
}
destroyApp()
{
System.out.println("E");
System.out.println("F");
}
Output:
A
E
F
Output (alternative):
A
C
D
Are the outputs above possible scenarii ?
MIDP javadoc answers it
"If a Runtime exception occurs during startApp() the MIDlet will be destroyed IMMEDIATELY. Its destroyApp() will be called allowing the MIDlet to cleanup."
and the similarly for pauseApp()
and destroyApp()
.
So answer the OP it is NOT guaranteed to execute the method atomically. A runtime exception
can/will change the state of the MIDlet and in effect the execution flow.