Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个不断运行的服务器,当我关闭它时,我需要它来检测它正在关闭,因此它会自动关闭套接字。无论如何,看看控制台是否正在关闭?我没有使用 Java2D 或类似的东西!
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable(){ public void run(){ //Shutdown here } }));
This is closest you'll get to what your looking for...