Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Abnormal Termination

 
Sumit Mehrotra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am facing a problem regarding abnormal termination of java program.When some one destroys a java program process from task manager, i need to modify something in the DB.I want to know what method is called when the program is about to exit abnormally.
regards,
Sumit
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the API docs for Runtime.addShutdownHook(Thread hook). That may serve your puprose. Pay particular attention to this:

Shutdown hooks should also finish their work quickly. When a program invokes exit the expectation is that the virtual machine will promptly shut down and exit. When the virtual machine is terminated due to user logoff or system shutdown the underlying operating system may only allow a fixed amount of time in which to shut down and exit. It is therefore inadvisable to attempt any user interaction or to perform a long-running computation in a shutdown hook.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic