Runtime.removeShutdownHook(Thread hook) has the following syntax.
public boolean removeShutdownHook(Thread hook)
In the following code shows how to use Runtime.removeShutdownHook(Thread hook) method.
/*w w w . j a v a2 s . c om*/ class Message extends Thread { public void run() { System.out.println("Bye."); } } public class Main { public static void main(String[] args) { try { Message p = new Message(); // register Message as shutdown hook Runtime.getRuntime().addShutdownHook(p); // remove the hook Runtime.getRuntime().removeShutdownHook(p); System.out.println("Program is closing..."); } catch (Exception e) { e.printStackTrace(); } } }
The code above generates the following result.