Re: [Simpleweb-Support] 8. Re: How to shutdown?
Brought to you by:
niallg
From: <sth...@go...> - 2007-04-11 08:03:15
|
Hi Pat, You seem to be using this facility to discard objects gracefully while the JVM is shutting down? But I wonder, if this still works, even if I wouldn't want shut down the whole JVM but just my Simple server? -Stefan 2007/3/29, R Pat <pat...@gm...>: > Sent again with a correct message's obejct (sorry)... > > Hi Stephan, > > Something that works perfectly for me: > > public class MyServer implements Runnable { > > public void run() { > System.err.println ("Server is shutting down..."); > > // Close all (simple's connection, others)... > ........ > > // This finalize all simpleweb's threads > Runtime.getRuntime().runFinalization(); > } > > public final static void shutdown() { > // Shutdown your Simple server and exit! > Runtime.getRuntime().exit(0); > } > > protected MyServer() { > Thread shutdownHook = new Thread(this, "shutdown-hook"); > > Runtime.getRuntime().addShutdownHook(shutdownHook); > } > } > > Regards, > Pat > |