feat: Add comprehensive examples from multithreading and hashing lectures
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user