Click here to watch in Youtube :
Click the below Image to Enlarge
![]() |
| Java Tutorial : Java Threads (Thread Sleep | Thread sleep in java_V2) |
public class SleepMessages
{
public static void main(String args[]) throws InterruptedException
{
String messages[] =
{ "Hello good morning", "Did you eat", "I am going to walk",
"Good night" };
for (String message : messages)
{
// Pause for 5 seconds
Thread.sleep(5000);
// Print a message
System.out.println(message);
}
}
}
Hello good morning
Did you eat
I am going to walk
Good night
Click the below link to download the code:

No comments:
Post a Comment