I create a thread to process some queue data. Inside the thread there is a unlimited while loop. when loop is working, the interface always freezing.
Im confused about this, I’ve created the thread, but why it still freezing ??
Thread queue = new Thread(new Runnable() {
public void run() {
while(true) {
...
}
}
});
queue.start;
Any solution for this problem ?
Its not just your interface slowing down, in fact your phone will be too because you are consuming (unnecessarily wasting) all the processing powers in a while loop. For better approach, use Handler and/or AsyncTask or at least use
Thread.sleepinside while-loop in your thread.