title: Using Thread.run() execute two threads simultaneously in an Enhanced loop
body: <pre><code>public abstract class Multithread implements Runnable{
      static Thread t1 = new Thread(){
          public  synchronized void run(){
              try {
                  for(;;){
                      System.out.println("java");
                      t1.sleep(300);
                  }
              } catch (Exception e) {
                  System.out.println("Exception"+e);
              }
          }
      };
      static Thread t2 = new Thread(){
          public  synchronized void  run(){
              try{
                  for(;;){
                      System.out.println("world");
                      t2.sleep(300);
                  }
              }catch(Exception e){
                  System.out.println("Exception"+e);
              }
          }
      };
      public static void main(String[] args) {
          try{
              t1.start();
              t2.start();
          }catch(Exception e){
              System.out.println("Exception "+e);
          }
      }
      @Override
      public void run() {
          System.out.println("running");
      }
  }
  </code></pre>
  
  <p><strong>Excepted O/P:</strong></p>
  
  <pre><code>java
  world
  java
  world
  java
  world
  .
  .
  .
  .
  </code></pre>
  
  <p><strong>observed</strong>
  I tried using sleep() for the threads,they are  getting overlapped at some point of time like this-</p>
  
  <pre><code>java
  java
  world
  java
  world
  world 
  java 
  ..
  </code></pre>
  
  <p><strong>Expected</strong>
  i need these two threads to run in parallel and it should not get overlapped,either of the thread can be started. Any idea?</p>