• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to design dead lock cleaner

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic