Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Graceful clean up of daemon process

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If my daemon process does not have a remote hook, such as RMI/JMX, that can signal it to shut down gracefully, what is the next best way to do some clean up before the JVM terminates?

This process have several daemon threads that may still be working. If there's some clean up hook that can be registered to the JVM, is there a limit on how long can the clean up code runs before the OS kills the process?

The process is likely to be terminated by "ctrl-c" or linux "kill" command.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the method addShutdownHook in java.lang.Runtime.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic