Note that there are some explanatory texts on larger screens.

plurals
  1. POAsyncTask performance issue on many AsyncTasks spawning.
    primarykey
    data
    text
    <p>I'm trying to create a lazy image loader for images both from device and from the web for a <code>ListView</code>. I'm thinking of what to use and how, on one hand I can use a thread that pools my request (always running, and I can attach a view and an adapter and it will handle the image loading for me), cache my already loaded images and checks for the visibility of the images before I load so I wont do unneeded job.</p> <p>I had another thought of using the <code>AsyncTask</code> like many suggest in the forum. There is one drawback though. I see that many use <code>new MyTask().execute(urls);</code> this presents a problem if I want to start loading and stop loading images on demand. If I use the async task per image then I need new async task for each image, that's a lot of 'new' to make, I can use a pool, but if too many async tasks are stuck, I will still create about 150-200 asyc tasks, too many for my taste...</p> <p>What do you guys think? I think a thread will do a nicer job here:</p> <ol> <li>Keep on running till killed</li> <li>Try to get a job from the queue, if not jobs, wait.</li> <li>If a job is available, get it and start processing.</li> <li>Each request is processed alone,serially and blocks the thread.</li> <li>Once does goes on with '2'.</li> <li>Each enqueue that is done by the adapter using <code>startLoadingImage()</code> for views that need to be displayed will create anew job and call notify on the wait lock.</li> </ol> <p>I can optimize this code with a pool of threads if I want several GET\POST requests in parallel. Also I'm caching the images I already downloaded\loaded for fast load on next access. The idea is to minimize GC and lists lagging.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload