23 lines
483 B
Java
23 lines
483 B
Java
package lecture.multithreading.timeout;
|
|
|
|
public class MyRunnable implements Runnable{
|
|
|
|
@Override
|
|
public void run(){
|
|
|
|
for (int i = 1; i <= 10 ; i++){
|
|
try {
|
|
Thread.sleep(1000);
|
|
} catch (InterruptedException e) {
|
|
System.out.println("thread was interrupted");
|
|
}
|
|
|
|
if(i == 10){
|
|
System.out.println("time is up");
|
|
System.exit(0);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|