title: JAVA Trying to run the sleep method within the runnable object put into the new thread
body: <p>I am trying to make a thread sleep from within the run() method of the class i  am using in the thread i am creating thus having the thread sleep when its called and i am receiving and error from eclipse. The objective is just to test out the code several times and see that the threads output at different times as i know choosing threads to run is not a decided thing. </p>
  
  <p>my code is as follows </p>
  
  <pre><code>    package multithreading;
  
      public class Mainclass {
  
          public static void main(String[] args) {
              run work= new run();
  
              Thread thread = new Thread(work);
  
              thread.start();
  
              System.out.println("main thread is running");
  
          }// end of main
  
      }// end of class mainclass
  </code></pre>
  
  <p>down here is the run class that i am creating an instance/object of in main up above</p>
  
  <pre><code>public class Run implements Runnable{// this is the beggining of the class
  
      public void run(){
  
          try {   
               thread.sleep(200); 
          }catch (InterruptedException ex) {
  
          }
          System.out.println("the second thread is running");
      }// end of run method of the class run
  }// end of class run
  </code></pre>
  
  <p>any help would be greatly appreaciated</p>