Converting MIDP threading applications to Sidekick

While porting to the Sidekick platform one of the most mysterious issues I was fighting with were massive application slowdowns. What was most interesting they happened e.g. on the menu screen which, after it’s initialized, is basically a static screen. After trying various approaches I started to think 😛 and remembered I read something about threading issues in “Java ME Applications on the hiptop Platform” document (available from Danger’s developer site).

The native hiptop programming model is very much event driven. Hiptop applications tend to react only to system or timer events or user input events delivered from the hiptop’s main event thread. On the other hand, MIDP applications—especially games—tend to be thread-driven, typically with a primary thread or timer thread driving all the action. This mismatch of programming styles can be a source of problems.
MIDP applications that are lax about thread synchronization and locking on more permissive devices will run into erratic and seemingly intractable performance issues on the hiptop.

Aha! That’s something interesting. Without much delay I started to refactor the game to use Timer class instead of threads and in a few hours of work I had a perfectly smooth running application 🙂

Timer is easy to use but a good example never hurts, does it?

Timer timer = new Timer(UPDATE_DELAY, true, new Listener() {
public boolean receiveEvent(Event evt) {
return true;

You can start and stop timer as many times as you can which is certainly a nice feature. Happy coding! 🙂


Tags: , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: