This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Client waiting for lock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Client waiting for lock" Watch "Client waiting for lock" New topic

Client waiting for lock

Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi All,
I have been testing locking and unlocking and need some opinions on how long should a client wait for lock. I have set up a test client program that randomly locks a record, sleeps for a random time, unlocks the record and repeats the process for a random number of loops. On the last loop there is a 50% chance that the client will not unlock the last record (I know those are ridiculous odds) simulating a client crash. I set up a batch file to start 7 clients and everything works fine. If a client "crashes", eventually the remaining threads will all try to lock the record that the crashing client locked. The problem here is that there is about a 15 minute wait before unreferenced is called on the crashing client's remote object.
Should clients give up on a lock before unreferenced is called? Maybe the client should be given the option to continue or give up? What would a good wait period be before giving up?
Thanks for your opinions
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Anurag Mishra
Ranch Hand

Joined: Sep 27, 2001
Posts: 133
According To sun specification you don't have to worry about client crashes, Client should only wait till the record unlocked by the server, record locking should be performed on the server side with the help of seperate class.
Anurag Mishra
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
If it really concerns you, you can always use a command line parameter to reduce the RMI DGC lease time (forgot the name of the system property; it's in the RMI docs). But Anurag is right: I wouldn't worry.
- Peter
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Thanks guys. It is definitely not a requirement to do anything but wait on a long block. Just wanted opinions.
Michael Morris
I agree. Here's the link:
subject: Client waiting for lock
Similar Threads
synchronized on method or object
Garbage Collection and Unreferenced
NX:Client crashed cause deadlock in LockManager
The mysterious 65/80 locking score
My Choices