Fortunately, the
Runtime class provides mechanism for adding a shutdown hook. The shutdown hook code below was added to the constructor. The shutdown method is invoked when the application is shutdown, for example CTRL+C.// add shutdown hook to stop server
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
shutdown();
}
});
}
public void shutdown() {
// add code to cleanly shutdown service here.
}

0 comments :
Post a Comment