
public class InterruptedExample {
	public static void main(String[] args) {
		final Thread sleepThread = new Thread(new Runnable() {
			public void run() {
				long startTime = System.currentTimeMillis();
				try {
					Thread.sleep(4000);
				} catch (InterruptedException e) {
					System.out.println("Sleep has been interrupted after " 
							+ (System.currentTimeMillis() - startTime) + " seconds");
				}
				System.out.println("Still going, just doing something different");
			}
		});
		sleepThread.start();
		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		sleepThread.interrupt();
	}
}

