how do I use Thread.sleep????????
Closed this issue · 2 comments
simonblaustein commented
how do I use Thread.sleep????????
i-am-zach commented
- Wrap your program in a "try-catch"
public class MyProgram extends ConsoleProgram {
public void run() {
try {
// Your code goes here
} catch(Exception e) {
// Leave this empty
}
}
}
- Use Thread.sleep to pause the program
public class MyProgram extends ConsoleProgram {
public void run() {
try {
System.out.println("Please wait one second");
Thread.sleep(1000); // 1000 -> 1000 miliseconds or one second
System.out.println("Thank you!");
} catch(Exception e) {
// Leave this empty
}
}
}
i-am-zach commented
Do not worry about understanding what a "try-catch" is yet. You will learn about it in a later unit!