ANDROID - While loop inside Thread

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 ?

Answers


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.sleep inside while-loop in your thread.


Need Your Help

ImportError (encodings) when calling video player with python script from parent media center Kodi

python python-3.x homebrew kodi vapoursynth

I'm trying to use the video player mpv with vapoursynth filter, which itself uses Python 3, as external player in the media center Kodi. mpv shortly flashes up in the Dock, then it crashes, accompa...