title: Coming from C#, How do I code simple multi-threading in Java?
body: <p>I am new to Java and do not have a lot of experience with multi-threading. Here is some multi-threading code I have in C#.net:</p>
  
  <pre><code>public class MultiThread 
  {
      Thread t1,t2,t3;
  
      public MultiThread()
      {
          t1=new Thread(m1);
  
          t2=new Thread(m2);
  
          t1.start();
  
          t2.start();
      }
  
      public void m1()
      {
          for(int i=0;i&lt;100;i++)
  
          Console.Write Line(i);
      }
  
      public void m2()
      {
          for (int i=0;i&lt;100;i++)
  
          Console.Write Line(i);
      }
  
      public static void main() 
      {
          MultiThread mm=new MultiThread();
      }
  }
  </code></pre>
  
  <p>As per the multi Threading definition(executing sub processes concurrently) m1() and m2() are two different sub processes ...so in this program they(m1 and m2) execute simultaneously</p>
  
  <p>If we look at this Java mult-threading code:</p>
  
  <pre><code>public class MultiThread extends Thread {
  
      public void run(){
          for (int i=0;i&lt;100;i++){
  
              System.out.println(i);
          }
      }
  
      public static void main(String[] args) {
  
          MultiThread t1=new MultiThread();
  
          MultiThread t2=new MultiThread();
  
          t1.start();
  
          t2.start();
      }
  }
  </code></pre>
  
  <p>This code contains only one method (a sub process or only one thread).</p>
  
  <p>How can I achieve multi-threading in Java?</p>
  
  <p>Thank you for the help.</p>