File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to design dead lock cleaner

 
Along huang
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I create a daemon thread as dead lock cleaner,which will kill a thread having locked database for a minute. But the problem is,How do the Cleaner know the time a thread locking?

regards
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Along,

I would recommend against having a thread kill off locks that have been hanging around too long. Not only the instructions do not require this, but my reading of the instructions would lead me to believe that the lock would remain valid for as long as my client application wanted it to stay valid.

You may wish to look at the recent topics talking about RMI Connection Factories, and using this in conjunction with either the Unreferenced interface or a WeakHashMap to do dead client cleanups.

If you do want to have a timeout, then you are going to have to have some way of storing the time the lock was granted with the lock itself - possibly have a lock object which holds these details.

Regards, Andrew
[ July 06, 2004: Message edited by: Andrew Monkhouse ]
 
Along huang
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!

I thought over and over, and the conclusion is that I never use dead lock cleaner.

Because my design adopt the optimistic lock, i.e. user can't lock a record when selecting a data row in JTable. for update functionality, I envelop the update() and lock() given by instruction, just provide client program a method executeUpdate() that refer to update() and lock(),
and executeUpdate() run at server side, so never occur dead lock situation.

and I don't use cookie, but I read some guideline book, most of them recommend to use cookie to uniquely identify the locking thread, I am not sure my design at this aspect.

best regards!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic