title: How To Create Dynamic Threads in Java
body: <p>I am trying to learn how to create a specified number of threads by the user in the console . There is not much to help me on and would like a detailed description on how to create a dynamic amount of threads. i know how to get the users input into a program using scanner but need help with the thread creation </p>
  
  <p>i have tried to use this method as it makes the most amount of sense to me (i am a very amateur programmer studying CS):<a href="https://stackoverflow.com/questions/9874587/how-to-create-threads-dynamically">How to create threads dynamically?</a></p>
  
  <p>my code </p>
  
  <p>package threads;</p>
  
  <pre><code> public class morethreads {
     public Runnable MyRunnable;
         public void run() {
          for (int i = 0; i&lt;20; i++)
          System.out.println("Hello from a thread!" + i);
         }
      public void main(String args[]) {
      Thread[] hello = new Thread [10];//amount of threads
      for(int b =0; b &lt; hello.length; b++){
          hello[b] = new Thread(MyRunnable);//&lt;&lt;this is the issue 
          hello[b].start();
       }
    }
  }
  </code></pre>