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
@@ -0,0 +1,22 @@
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);
}
}
}
}