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
  •  | 
  •  

Pregunta

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 ?

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top