|Using Shutdown Hooks [message #290808]
||Thu, 01 September 2005 16:12
Originally posted by: L.Ugolini.NO_SPAM_quinary.it|
I tried to use Runtime.getRuntime().addShutdownHook() by clicking
terminate in Eclipse and it never calls the shutdown hook.
Here's the code:
public static void main(String args) throws Exception
System.setOut(new PrintStream(new File("TrapExit.out")));
Thread shutdownHook = new Thread()
public void run()
System.out.println("*** END ***");
It works fine out of Eclipse, as launching it via command line and then
closing the windows after a while, I actually find the String ""*** END
***"" in the output file.
Note also that if I remove the row "while (true)" it works fine both in
and out of Eclipse.
Does anyone know if there is a way to make it works by clicking the
terminate button inside Eclipse?
Thanks a lot,
Powered by FUDForum
. Page generated in 0.02495 seconds