Has anyone else had issues with threading on the 8100/8700?

I recently wrote a Blackberry App that uses threads and integrates with Notes using email and Notes agents. 

Originally written for the 7290 the app is now being used on mixed Blackberry devices including the 7290, 8100, 8700 and Pearl.  Whilst it ran fine on the 7290 a problem was discovered as soon as we tested on the 8100.  The threads that were being created were not terminating appropriately and I could see each new thread running concurrently.

Here's problem: I use a thread to manage some aspects of a work activity created by the user.  When the user stops working on that activity I want the thread to stop and die and I email details of the activity to a mail-in database on the Domino server or later if GPRS isn't available. 

The Java spec suggests that when a threads exits it's run method it should die.  So in the run method of my thread I do something like this:

   public void run() {

      try {

      while (!stopPressed) {
            // Do some work....................
          }
      } catch (Exception e) {
         System.out.println("Timer stopping");
     }
}

When the user stops the current activity via the menu I set the variable stopPressed to true and expect the thread to die as the run method finishes.  I then create a new thread when the next activity is started.

On the 7290 this works fine with the thread dying as expected.  On the 8100 and 8700 the thread didn't die and so both the existing thread and my new thread were left working. 

The real app is a bit more complicated than this but that's the basic idea.  With me so far?

In the end I simply created one thread for the life of the application rather than one thread for each activity created by the user. 

I'm wondering has anyone else experienced threading issues like this on the later Blackberry devices?

 
Trackbacks
  • Trackbacks are closed for this post.
Comments

  • 11/15/2006 4:49 PM Kerr wrote:
    If the thread is still doing work then either stopPressed is not being set to true or there is another loop inside '//do work...' that isn't allowing the stopPressed variable to be checked.

    Even if the thread object was still in existance, if that loop exited, the thread would just be cluttering up the place, but not causing any other trouble.
  • 11/16/2006 2:09 AM David Taig wrote:
    Sorry unable to help, however have you developed a secondary Address Book with the same functionally as on the BlackBerry. The ECL examples on BlackBerry Developers web site don't cut it..
    1. 11/16/2006 8:56 AM Jason Hook wrote:
      Hello,  Thank You for your comment.  I haven't developed a secondary address book.  A lot of the stuff on the BB developers site is really good but from time to time there are big gaps.........
Leave a comment

Comments are closed.