class MyThread1 implements Runnable { public void run() { try { Thread.sleep(40000); } catch (Exception exc) { System.out.println(Thread.currentThread().getName() + " is interrupted."); } System.out.println(Thread.currentThread().getName() + " is exiting."); } } public class ThreadInterrupt1 { public static void main(String args[]) throws Exception { Thread th1 = new Thread(new MyThread1(), "First Thread"); Thread th2 = new Thread(new MyThread1(), "Second Thread"); th1.start(); Thread.sleep(200); th1.interrupt(); th2.start(); Thread.sleep(500); th2.interrupt(); } }