AbstractIdleService

该类有一个startup和shutdown方法,启动此服务或者结束此服务的时候可以调用。

Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
if (gameServer.isRunning()) {
gameServer.stopAsync();
gameServer.awaitTerminated();
}
}
});

这样就可以监听他的服务结束事件了。。。。
来自:http://blog.csdn.net/u011415720/article/details/51482601
原文地址:https://www.cnblogs.com/vhyc/p/7735651.html