[Simpleweb-Support] A clean way to shutdown the server ?
Brought to you by:
niallg
|
From: R P. <pat...@gm...> - 2006-11-02 10:13:27
|
Hi Nial,
Something that looks right to shutdown the server (it works for me):
public class MyServer implements Runnable {
public void run() {
System.err.println("Server is shutting down...");
// Close all...
........
// This finalize all simpleweb's threads
Runtime.getRuntime().runFinalization();
}
protected final static void shutdown() {
Runtime.getRuntime().exit(0);
}
protected MyServer() {
Thread shutdownHook = new Thread(this, "shutdown-hook");
Runtime.getRuntime().addShutdownHook(shutdownHook);
}
}
Regards,
Patrick
|