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 } }));
これは、探しているものに最も近いものです...