It's not a secret anymore!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Locking Question with cancel ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Locking Question with cancel ???" Watch "Locking Question with cancel ???" New topic

Locking Question with cancel ???

Mick Hoffman

Joined: Feb 14, 2006
Posts: 1
Hi i am currently doing the URLyBird assignment, and something has me sorta stumped.
I understand how to lock, but the real problem if anyone was making a locking system with Sun's specifications for the CPU to do nothing till it is unlocked, the user would want a cancel button.

Should i try and implement a cancel button to stop waiting but the only way i can think to do that currently is by the client creating a new connection and disconnecting the old one. The reason why i say this is cause currently in my code the server connection won't listen again till after the lock method has finished. and by disconnecting on my server will cause that connection to release any locks on any Records, but having a client disconnect and reconnect seems like a really bad way to have a program.

does any one have any ideas around this problem or should i just not have a cancel button but as you all know this means the client program will tend to hang while waiting for the lock record.

any help would be greatly appriciated
Lara McCarver
Ranch Hand

Joined: Dec 09, 2003
Posts: 118
I don't think you need a Cancel button. The only reason the client should be doing a lot of waiting is in a deadlock scenario, which I would advise you to prevent. Yes, the client has to wait on the lock, but the lock should only be active when a record is being updated, and that will take such a short amount of time that ordinarily no one will notice.

In fact, if you add a Cancel button, I think you will have a tough time testing it because the record won't be locked long enough

I agree. Here's the link:
subject: Locking Question with cancel ???
It's not a secret anymore!