Listview asynchronous loading picture, threading issues

Loading in a list of listview picture, I started to do so, a picture can use to create a thread to load, and then the pictures to load address as a key in a map set to control the same picture when no loaded again create a thread, but this like the issue came. When I slip quickly list, like this will add some new different address pictures, but before loading pictures thread and haven't finished loading, this appearance how can not loaded thread stop.

Started by Upton at December 08, 2016 - 1:36 PM

Very good, very powerful

Posted by Armstrong at December 12, 2016 - 2:27 PM

It's CPU and memory consumption,
General loading listView picture of a thread can.


Like this.
new Thread(){
public void run(){
for (String url: imgURLs) {
Bitmap bitmap = downloadImage(url);
if (bitmap != null) {
_map.put(url,bitmap); //The cache, download will not be downloaded.
// The UI thread to update the image to ListView
Message msg = new Message();
msg.what = 1;
msg.obj = bitmap;
handler.sendMessage(msg);
}
}
}
}.start();

Posted by Natalie at December 18, 2016 - 2:55 PM

The two floor of a friend you just open a thread, normally a screen can display 6 to 8 data like this, it is equivalent to the other pictures load will be in a state of waiting to load, so that a load will not be good.
My question is whether to open several threads are good, how to solve the scrolling list or fast drag list words how to deal with those not executed threads when loading new data.

Posted by Upton at December 23, 2016 - 3:20 PM

The thread cannot stop immediately, when the JVM garbage recycling is a process, if we create a thread that APP easy consumption, consumption of memory.
Personally think that a thread, or 2 threads is enough. Unless the network environment is poor or normal or quickly gets to the picture content.
To stop the thread can be forced to call the stop method, increase the flag. But they cannot stop immediately.

Posted by Natalie at December 28, 2016 - 3:40 PM