Running code on program exit in Java [duplicate]

Use Runtime.getRuntime().addShutdownHook(Thread).

Leave a Comment