multithreading - JAVA Trying to run the sleep method within the runnable object put into the new thread -


i trying make thread sleep within run() method of class using in thread creating having thread sleep when called , receiving , error eclipse. objective test out code several times , see threads output @ different times know choosing threads run not decided thing.

my code follows

    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 running");          }// end of main      }// end of class mainclass 

down here run class creating instance/object of in main above

public class run implements runnable{// beggining of class      public void run(){          try {                 thread.sleep(200);          }catch (interruptedexception ex) {          }         system.out.println("the second thread running");     }// end of run method of class run }// end of class run 

any appreaciated

sleep static method of thread. java case sensitive.

try using thread.sleep instead of thread.sleep


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -