class MyThread implements Runnable {
public void run() {
try {
Thread.sleep(500);
System.out.println("run()");
} catch (Exception e) {
System.out.println("Exception: " + e);
}
System.out.println("Thread is running");
}
}
class Program {
public static void main(String[] args) {
try {
Thread trd = new Thread(new MyThread());
trd.start();
trd.interrupt();
} catch (Exception e) {
System.out.println("Exception: " + e);
}
}
}
/*
run:
Exception: java.lang.InterruptedException: sleep interrupted
Thread is running
*/