/*********************************************************
 * 
 * @author Sun
 * Two overloaded versions of sleep are provided: one that specifies 
 * the sleep time to the millisecond and one that specifies the sleep 
 * time to the nanosecond. However, these sleep times are not guaranteed 
 * to be precise, because they are limited by the facilities provided by 
 * the underlying OS. Also, the sleep period can be terminated by 
 * interrupts, as we'll see in a later section. In any case, you 
 * cannot assume that invoking sleep will suspend the thread for 
 * precisely the time period specified.
 * 
 * The SleepMessages example uses sleep to print messages at four-second intervals: 
 *
 */
public class SleepMessages {
    public static void main(String args[]) throws InterruptedException {
        String importantInfo[] = {
            "Mares eat oats",
            "Does eat oats",
            "Little lambs eat ivy",
            "A kid will eat ivy too"
        };

        for (int i = 0; i < importantInfo.length; i++) {
            //Pause for 4 seconds
            Thread.sleep(4000);
            //Print a message
            System.out.println(importantInfo[i]);
        }
    }
}