I have an async image loader that loads images as they come into queue.
async task is pretty simple:

protected Void doInBackground(Void... params) {
try {
while (true) {

if (imageQueue.size() == 0) {
synchronized (imageQueue) {
imageQueue.wait();
}
}

if (imageQueue.size() > 0) {
// loading images 
}

if (Thread.interrupted()){
break;
}

}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

And call notifyAll on adding another image to queue, seems pretty straight 
forward. 

The thing is, after this task is executed, every other asyncTask in the app 
stops working or to put it more accurately, never goes beond onPreExecute. 
However if I run this code as a runnable inside a Thread everything works 
fine. The strange thing is, it is not reproducable in the emulator, but it 
always happenes on my Samsung Galxy S2 (haven't tested on other hardware).
Maybe someone had a similar problem, or might have some insights why is 
this happenening? I think it might have something to do with how android 
manages its thread pool, asyncTask recycling or something like that?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to