06-21-2013 10:02 PM
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?
06-22-2013 04:46 AM
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?