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.
プログラムが終了する直前に、コンソールアプリケーションでいくつかのオブジェクトをシリアル化したいですか (このコードをメインメソッドの最後に追加するだけではありません)?
解決することは可能ですか?
以下のように、shutDownHook を登録できます。
public class Task implements Runnable { public void run() { yourWork(); } } public class App{ static { Runtime.getRuntime().addShutDownHook(new Thread(new Task())); } public static void main(String[] args){ . . . } }