Thread.sleep() : Sleeping « Thread « SCJP






A sleeping thread passes time doing nothing and without using the CPU. 

sleep(), like yield(), is static. Both methods operate on the currently executing thread.

public class MainClass{
    public static void main(String[] argv) throws Exception{
       Thread.sleep(1000);
    }
}

When a thread goes to sleep, its locks will be unavailable to other threads.

Sleeping is used to delay execution for a period of time.
No locks are released when a thread goes to sleep.

A sleeping thread is guaranteed to sleep for at least the time specified
There is no guarantee when the awakened thread will return to running.

The sleep() method is a static method that sleeps the currently executing thread's state. 
One thread cannot tell another thread to sleep.








7.7.Sleeping
7.7.1.Thread.sleep()
7.7.2.Sleeping for a While