• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to perform a task when EXIT [ALT-F4 or apl termination]  RSS feed

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Without getting into too much technicality, I have an application that uses a LOCK on a viewed record (user A press double click on a record --> new frame with information + Lock. No one else can access this info until user A has finished watching it]--> unlock the Frame) .

when the program exits I always *make sure* that those locks are unlocked (so someone else can use them).

There are some 'Exits' that I cannot control (e.g., a computer's reset).

Question how can i make sure that the application will perform unlock when:

1. the user has pressed ALT-F4(without disabling the option)
2. The user has terminated the application from the Windows Task Manger
3. Computer's reset?

Other ideas to solve this problem will be helpful



Thanks
GWB
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.Runtime.addShutdownHook(Thread)
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
[ September 21, 2004: Message edited by: Vlado Zajac ]
 
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you use:
java.nio.channels
Class FileLock
?
 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't. Do you have any code to show.
Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!