FileDocCategorySizeDatePackage
InterruptTest.javaAPI DocExample515Sun Jul 13 15:31:00 BST 1997None

InterruptTest.java

public class InterruptTest implements Runnable {

	public static void main( String [] args ) throws Exception {
		Thread sleepyThread = new Thread( new InterruptTest() );
		sleepyThread.start();

		Thread.sleep(500);
		sleepyThread.interrupt();
		Thread.sleep(500);
		sleepyThread.interrupt();
	}
	
	public void run() {
		while ( true ) {
			try {
				System.out.println("Sleeping...");
				Thread.sleep( 1000*1000 );
			} catch ( InterruptedException e ) {
				System.out.println("interrupted...");
			}
		}
	}
}