class ERR { static public void println(String msg){ System.err.println(Thread.currentThread().toString() + ": " + msg); } } class MyThread extends Thread { Thread parent; public MyThread() {parent = Thread.currentThread();} public void run() { ERR.println("Hello"); try {this.sleep(2);} catch (InterruptedException ie) {} parent.interrupt(); } } class Main { public static void main(String[] argv) throws InterruptedException { MyThread aThread = new MyThread(); ERR.println("this is main"); aThread.start(); // calls run() try { aThread.join(); if (Thread.currentThread().isInterrupted()) { ERR.println("Have been interrupted"); throw new InterruptedException("Suicide..."); } } catch (InterruptedException ie) { ERR.println("Un-joinable:" + ie); throw ie; } finally { ERR.println("Bye"); } ERR.println("Never printed..."); } }