Is MIDlet.startApp() guaranteed to be executed fully before MIDlet.pauseApp() or MIDlet.destroyApp() is called?

StackOverflow https://stackoverflow.com/questions/8632897

  •  30-03-2021
  •  | 
  •  

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top