title: Android - How to create multiple threads to run at background?
body: <p>I am new to Android, but I ran into this problem... 
  I need an infinite loop to run some process in the background, 
  while another infinite loop to accept some socket connection, 
  and then when a button clicked, I need to make a socket connection to some server.</p>
  
  <p>Almost all the example and tutorial I can find are showing how to create one single thread.</p>
  
  <p>I have try to use runnable (this seems to run at foreground?)</p>
  
  <pre><code>Runnable r=new Runnable() { 
    public void run()  { 
      while(true){}
    } 
  }; r.run(); 
  </code></pre>
  
  <p>and I have tried to use AsyncTask (this run at background, but only one AsyncTask per activity?)</p>
  
  <pre><code>private class Run extends AsyncTask&lt;Void, Void, Void&gt; {
    protected Void doInBackground(Void... params) {
    }
  }
  </code></pre>
  
  <p>but whatever I do, my program only execute the first thread.</p>
  
  <p>My question would be, is it possible to have multi-thread running multi-infinite loop within one activity? If is, how?</p>