When you develop applications for the BlackBerry smartphone, any network communication or lengthy data processing should be performed in its own thread. This is easy to realize for network input/output (I/O) because network connections must be initiated in their own thread, otherwise a deadlock situation may occur.
When an application performs lengthy processing on the main event thread, the BlackBerry smartphone user can perceive the application to be slow because it is unable to process input commands. In an extreme situation, the application can close if it blocks or ties up the main event thread. If an application ties up the main event thread, the system is unable to dispatch messages to it (for example, BlackBerry smartphone user input, UI updates or network I/O). If the application message queue exceeds its limit, the application is terminated with the one of the following errors:
Process [application name] killed due to message queue overflow
Uncaught Exception: [ApplicationName] is not responding; process terminated
An application is blocking the main event thread.
The main event thread processes system messages. Blocking this thread prevents system messages from being processed and can lead to a message queue overflow.
Because there is a finite amount of storage space for messages, the issue is caused when these messages are not being processed. If an application stops processing messages for a long period of time, the system assumes that the application has stopped responding and is no longer functioning as expected. This is the reason why the process was terminated.
Move long processes or processes that block to a separate background thread.
Application stops responding when opening a connection
Flow of what is occurring
- Application opens connection
- UI pushing dialog box to the foreground
- BlackBerry is now locked
Flow of what should occur
- Application places a connection into a thread
- Application runs the connection in a thread off of the main event thread
- UI pushes dialog box to the foreground and thread execution is currently paused
- User is notified of connection and accepts
- System returns execution to the connection thread