title: How Thread run starts?
body: <p>I was looking a small example on Threads.For creating Threads we can do in 2 ways either by implementing <code>Runnable</code> interface or by extending Thread.I used the 1st way</p>
  
  <pre><code>package test;
  
  public class test implements Runnable{
      public static void main(String args[])
      {
          test t=new test();
          t.run();Thread th=Thread.currentThread();
          th.start();
      }
  
      @Override
      public void run() {
          // TODO Auto-generated method stub
          System.out.println("hi");
      }
  }
  </code></pre>
  
  <p>My doubt is when we are calling <code>th.start();</code> then <code>run()</code> is called.I want to know how.I thought internally there <code>start()</code> may be calling <code>run()</code> so I looked in the documentation of Thread class</p>
  
  <p>The following is the <code>start()</code> declaration in Thread class</p>
  
  <pre><code>public synchronized void start() {
      /**
       * This method is not invoked for the main method thread or "system"
       * group threads created/set up by the VM. Any new functionality added
       * to this method in the future may have to also be added to the VM.
       *
       * A zero status value corresponds to state "NEW".
       */
      if (threadStatus != 0)
          throw new IllegalThreadStateException();
  
      /* Notify the group that this thread is about to be started
       * so that it can be added to the group's list of threads
       * and the group's unstarted count can be decremented. */
      group.add(this);
  
      boolean started = false;
      try {
          start0();
          started = true;
      } finally {
          try {
              if (!started) {
                  group.threadStartFailed(this);
              }
          } catch (Throwable ignore) {
              /* do nothing. If start0 threw a Throwable then
                it will be passed up the call stack */
          }
      }
  }
  </code></pre>
  
  <p>As you can see inside <code>start()</code>,<code>run()</code> is not called but when we are calling <code>th.start()</code> then automatically overriden <code>run()</code> is called.Can anybody please throw some light in this</p>