feat: Complete timeout example for threading

This commit is contained in:
2026-05-24 18:29:12 +03:30
parent 83746b88f6
commit 31e359ff87
2 changed files with 38 additions and 1 deletions
@@ -1,10 +1,25 @@
package lecture.multithreading.timeout;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO
Scanner scanner = new Scanner(System.in);
System.out.println("you have 10 seconds: ");
System.out.print("enter your name: ");
MyRunnable myRunnable = new MyRunnable();
Thread thread = new Thread(myRunnable);
thread.setDaemon(true);
thread.start();
String name = scanner.nextLine();
System.out.println("hello " + name);
scanner.close();
}
}