Symbian
Symbian OS Library

FAQ-0451 Two Java apps run at the same time on an EPOC machine sometimes crash each other

[Index][spacer] [Previous] [Next]



 

Classification: Java Category: AWT
Created: 12/09/99 Modified: 07/03/2001
Number: FAQ-0451
Platform: ER5

Question:
Sometimes when I try to start a Java application while another is still running I get the "Starting" message for a short while. Then the application crashes, killing both app instances. What might be going wrong?

Answer:
Note: This is quite different from the similar problem which occurs on the emulator () and is specific to the emulator. It is not either a manifestation of OOM as such a problem would result in only the second instance crashing.

Rather the problem is a result of a shortcoming in the way java.awt.* has been implemented in EPOC Release 5. Each GUI-based Java app (process) which is launched on an EPOC machine has its own AWT Server thread. Now for each Java thread to find its own AWT Server, that server must have a unique name. The name currently assigned is "AWT Server xx" where xx means the two most significant digits of the AWT Server's process ID. Clearly this will not necessarily result in unique names once a sufficient number of processes have been started. And when threads from two different processes try to access the same AWT Server, both crash. Hence the observed behaviour.

In most cases, problems will not arise until after 1,000 threads have been launched. This is because:
  • New threads or processes are assigned IDs consecutively.
  • Launching a new Java process with a GUI typically results in eight or more new EPOC threads or processes.
  • Process numbers for consecutive Java app instances thus differ typically by eight or more.
  • The AWT Server names consequently have an 80% or better chance of remaining remaining distinct.

This will be fixed in the next EPOC release so that AWT Server threads genuinely have unique names. The only work around at the ER5 level if you confront this problem is to carry out a soft reboot of your machine. This will reset the thread/process counter to zero and allow you to launch 1,000 or so new threads without too much risk of such problems.

You can investigate what is going on by running the ps command in EShell (obtainable from the ER5 C++ SDK or from the EPOC World Web site). If you type "t" at the "ps>" command prompt, you will see all the current threads listed with their thread and process IDs, e.g.

AWT-Server 00
    ... ID 675 (Proc 669)
    which indicates that this AWT-Server thread has thread/process ID 675 and is running in the process with thread/process ID 669. Its name under ER5 will thus be "AWT Server 66".