title: Creating an unknown amount of threads in Java?
body: <p>Hi for a program I'm working on I need to complete a task using an variable amount of threads.  The class Mythread that extends Thread is stored within another class X I have created.</p>
  
  <p>What's supposed to happen is when I call X it passes a parameter n, that specifies the maximum amount of threads that can be used.  I'm not sure how to go about creating n amount of threads because everything I've read online states that a thread must be called explicitly like </p>
  
  <pre><code>Thread thread1 = new Mythread();
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>while (0 &gt;= n)
    {Thread thread1 = new Mythread(); n--;}
  </code></pre>
  
  <p>but this didn't work. Any ideas on how to go about doing this? Sorry if my problem is a little vague, it's for school and I want to learn the material on my own then post the bulk of the project.  If there's any other information you need or clarification feel free to ask.</p>