Hi,
I have come across some really strange behaviour with threads on the 7650 (the phone, not the emulator).
I have a game control thread, in a web-based game, that is constantly looping and checking to see if it needs to make any requests from the server. The http communication is also performed in this same thread (I'm trying to keep the communication serial, one request at a time, so I didn't see a need for a separate communication thread).
The thing is, when it's not your turn to play, the game thread will poll the server for updates, and then sleep for a few seconds. When it is your turn to play, the thread loops constantly waiting for flags to be set by the UI to send the requests, without any delays (no Thread.sleep()).
When I ran this on the emulator it worked perfectly, but as soon as I downloaded to the phone, I saw that when it is my turn to play (no sleeps in the thread), the phone would get completely stuck, and have no event handling.
I managed to solve this by putting a Thread.yield(), command at the end of the loop. But shouldn't the threads be managed automatically by the VM?
Has anyone experienced similar behaviour? Any solutions?
By the way, this was tested on a 7650 with firmware version 3.16.
Thanks.

Reply With Quote

