Thread Pool

Because the BlackBerry has rather constrained Thread count limitations we use a Thread pool to manage our threads. To run something in the Thread pool use the code: MobileApplication.instance().getApplication().getThreadPool() to get a reference to the application's thread pool and then call invokeLater() with a runnable object to run it in the Thread Pool. Here is a complete example:

      
MobileApplication.instance().getApplication().getThreadPool().invokeLater( new Runnable() {

       public void run() {
            System.out.println("I'm in a Thread Pool.");
       }
} );

This is different from calling Application.invokeLater() since the application invokeLater method runs your code on the event thread which could unnecessarily lock the UI.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© 2011 Metova, Inc.