26 lines
639 B
Java
26 lines
639 B
Java
package lecture.multithreading.basics;
|
|
|
|
|
|
public class SleepExample {
|
|
public static void main(String[] args) {
|
|
System.out.println("starting program");
|
|
|
|
try {
|
|
Thread.sleep(10000);
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
for (int i = 1; i <= 10; i++) {
|
|
System.out.println("Count: " + i);
|
|
|
|
try {
|
|
Thread.sleep(1000); // 1 second stop
|
|
} catch (InterruptedException e) {
|
|
System.out.println("Thread terminated!");
|
|
}
|
|
}
|
|
|
|
System.out.println("End of program");
|
|
}
|
|
} |