Reusing a thread
<p>I am trying to get my head around threads, and after attempting many times to get my head around it, I am stuck on this point.</p>

<p>I want to get some remote data from a server. I create a thread to handle this operation. I understand this. But if I want to get some more remote data, I end up creating a new thread. This seems a bit daft, as shouldnt I be able to re-use the existing thread.</p>

<p>After trying to understand how I could do this, I think the answer lies in sending messages to the thread? But I am totally baffled by this.</p>

<p>Here is a example of where I need to get lots of remote data based on a variable within a for statement:</p>

<pre><code>for(int i = 0; i &lt; jsonarray.length(); i++){
   String httpUserId = jsonarray.getJSONObject(i).getString("user_id");
   //Get Sub Comments
   userId = httpUserId
   Thread t = new Thread(null, getUserPrefs, "getUserPrefs");
   t.start();
}
</code></pre>

<p>As you can see in the example, I need to call the remote server lots of times, but instead of creating a new thread each time, shouldnt I be able to reuse one thread that I can create earlier?</p>

<p>If anyone can help I would be most grateful :)</p>
