Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 1,006
Registered: ‎05-22-2009
My Device: Not Specified

How to Handle the Threads to load the list of Images and Navigation between the screens



I am trying displaying the list of images in the listView.I am using single Thread to download the images ,on the clicking of single element in the listView ,I am navigating to next screen,at that time,I am stopping the thread,When I return to the list screen,Only half of the images are downloaded,How do i invoke thread again.


should i use 3 0r 4 threads in this case to download the images at the first time


How should this case be handled?





Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Handle the Threads to load the list of Images and Navigation between the screens

With respect to the overall approach, I personally find a Thread that executes 'Runnables' a better implementation.  So instead of adding a download URL to a Thread that just downloads images, you can create and pass in a Runnable to the Thread that processes Runnables.  Of course if you are downloading images, then the Runnable will be a network connection.


And in terms of controlling the number of downloads executing at once, you could look at a Thread Pool - this is not a specific BB concept, but it has been discussed here so search around here, or search generally. 


With respect to the number of downloads it is effective to have running at once, I don't think there is a right answer, I think it depends on the device and the network connection.  But I personally would limit myself to 2 or 3.


But getting back to your original question, from a programming perspective, I am not sure why you would stop the download Thread when you go into the Detail screen.  The user is going to come back to the List screen, so why not just leave the downloads running?