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