我在主方法中有以下内容:
public static void main(String[] args) throws IOException {
Properties properties = getConfig();
Jedis jedis = configure(properties)
jedis.subscribe(queueHandler, "queue");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
logger.debug("SHUTTING DOWN");
jedis.close();
}
});
}
我注意到我的关闭挂钩中的代码从未运行,这是为什么?如何清理主方法持有的资源?