Perry Smith

Java Questions & Answers

Home / Java Q & A Archive Page 4 / Java Q & A Archive / Java Main Page

sleep()
Tuesday, 23-Feb-99 19:42:23

24.128.241.48 writes:

I tried to call sleep(190) in main() but it says there is no sleep function in my main class. Do I have to put it in the run() method of my main class?

Judy


Response
Re: sleep()
Wednesday, 24-Feb-99 09:39:53

194.106.141.61 writes:

Use this....

      try{
      Thread.sleep(190);
      }
      catch(InterruptedException e){
      System.out.println("Sleep Interrupted");
      }
sleep(int) is a static method in the java.lang.Thread class, this means that you must refernece it using the name of the class in which it is defined.

Joe.


Home / Java Q & A Archive Page 4 / Java Q & A Archive / Java Main Page