I have a thread with a priority set to Thread.MIN_PRIORITY + 1
that does some image processing for me (resizing, reading and writing).
I've noticed that whenever that thread is working on an image, animations in my UI thread start to stutter and freeze up.
The priority is low enough such that animations should take a higher priority over that thread, and my CPU certainly isn't starved for resources.
Is there any particular reason this might be happening?
Edit - my thread:
public class WorkerQueue extends Thread {
public Handler handler;
int priority = Thread.MIN_PRIORITY + 1;
private static WorkerQueue self = null;
public static WorkerQueue getInstance() {
if (self == null) {
self = new WorkerQueue();
self.start();
self.setPriority(priority);
}
return self;
}
@Override
public void run() {
Looper.prepare();
handler = new Handler();
handler.getLooper().getThread().setPriority(priority);
Looper.loop();
}
public synchronized void enqueueTask(final Worker task) {
handler.post(new Runnable() {
@Override
public void run() {
task.run();
}
});
}
}