abdeen-ahmad
12/10/2015 - 5:57 PM

Shutdown thread

Shutdown thread

import java.io.IOException;

class MyThreads implements Runnable{

	@Override
	public void run() {
		
		System.out.println("I am shutting down");
		
	}
	
}
public class AnasShutDown {
	
	public static void main(String[]  args) {
		Thread myThread = new Thread(new MyThreads());
		Runtime.getRuntime().addShutdownHook(myThread);
		
		try {
			Runtime.getRuntime().exec("notepad");
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		System.exit(0);
	}
}