title: Java Threads yield method query
body: <p><strong>I am practising threads, I used yield(), iam expecting output as below: (BUT not getting as expected)</strong></p>
  
  <pre><code>One1
  Two1
  One2
  Two2
  One3
  Two3
  .
  .
  .
  .
  </code></pre>
  
  <p><strong>Whats wrong in my below code?</strong></p>
  
  <pre><code>public class Main2 {
  
      public static void main(String[] args) {
  
          MyThread myThread1 = new MyThread("One");
          MyThread myThread2 = new MyThread("Two");
  
          /*Thread t1 = new Thread(myThread1);
          Thread t2 = new Thread(myThread2);
  
          t1.start();
          t2.start();*/
  
  
          myThread1.start();
          myThread2.start();
      }
  }
  
  
  class MyThread extends Thread {
  
      private String name; 
  
      public MyThread(String name) {
          this.name = name;
      }
  
      public void run(){
  
          for(int i=1;i&lt;=20;i++) {
              System.out.println(name+i);
              yield();
          }
      }
  }
  </code></pre>
  
  <p><strong>and also I would like to know does commented statements correct to use or not? I mean below:</strong></p>
  
  <pre><code>Thread t1 = new Thread(myThread1);
  Thread t2 = new Thread(myThread2);
  
  t1.start();
  t2.start();
  </code></pre>
  
  <p>Waiting for your replies..</p>