26 lines
564 B
Java
26 lines
564 B
Java
package lecture.multithreading.timeout;
|
|
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class Main {
|
|
public static void main(String[] args) {
|
|
|
|
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();
|
|
}
|
|
}
|
|
|