title: Sleep method on child Thread causing Main Thread to sleep as well
body: <p>I created a very simple thread logic to see race condition but I saw an unexpected behavior and it makes me think I am missing some very important concept about Multithreading in Java.</p>
  
  <p>Here's my Thread Class</p>
  
  <pre><code>public class MyThreadDoinNothing implements Runnable {
      private int count = 0;
  
      @Override public void run() {
          count++;
          System.out.println(count);
      }
  }
  </code></pre>
  
  <p>And here is the MAIN</p>
  
  <pre><code>public class MAIN {
      public static void main(String[] args) throws InterruptedException {
          Thread[] threads=new Thread[100];
          Runnable object=new MyThreadDoinNothing();
          for (int i=0;i&lt;100;i++) {
              threads[i] = new Thread(object);
              threads[i].start();
              threads[i].sleep(1000);
          }
      }
  }
  </code></pre>
  
  <p>I expected MAIN thread to run for ~1s and print 100 numbers with race condition.But what is happening that its taking 100 second whole program.I though threads[i].sleep(1000) should have made only that particular thread to sleep not the MAIN.</p>
  
  <p>Not sure what I am missing here.</p>