This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes URLyBird Locking Queries 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 "URLyBird Locking Queries" Watch "URLyBird Locking Queries" New topic
Author

URLyBird Locking Queries

Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Hi All,
I had some queries related to Locking. Please could someone help me on the same?

1. The Locking strategy does not specify any Time out periods though i feel that it is essential. But would implementing that be changing the requirement?
2. If i implement the Time out strategy for locking then there could be a scenario where a person locks a record, updates it and then forgets to unlock. After the timeout i release the lock. But what about the update that is made? Should it be rolled back or must i retain that and commit?

Please could someone shed some light on the same?


-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
Leo Ho
Ranch Hand

Joined: Mar 31, 2005
Posts: 36
Sam, if your instructions say that you must make the calling thread give up CPU until the lock is free (like mine) then I suggest you must comply with that rule. There's no point in making the work more complicated, especially when it goes against what is specified in the instructions.

Leo.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
I don't roll back anything if a lock isn't released, I just kill the lock after a timeout period.

In fact I didn't provide for (and it wasn't asked in the assignment) for any rollback capability.


42
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Sam,

I don't know how are your specification but in mine thre is no time out specified.
To make some assumptions will increase the code complexity(see Leos post). On ther side which time out you'll choose and how you'll justify it ?

I am not shore that I undersant you point :

I don't roll back anything if a lock isn't released, I just kill the lock after a timeout period.


The time out purpose is to prevent the death locks - if you only release(you use "kill") the lock without release the thread them the thread (or client) is remain in waiting.

Regards, Mihai


SCJP, SCJD, SCWCD, OCPJBCD
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
When the lock is killed (using the unlock method of course) all threads waiting on it are automatically notified.

The timeout period is configurable, I document the period I chose based on the intended usage pattern of the engine.
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Jeroen,


The timeout period is configurable, I document the period I chose based on the intended usage pattern of the engine.


but how you can be shore that the timeout will work on all paltfroms ? Even if on your test machime(s) is working that does not means that on the examinatotrs macheine(s) will work also.
A configurable timeout is not bad, but to does not fulfill the requrermanets (at leasm mine)

Regards Mihai
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
That's what the versions.txt file is for. It documents the platforms you test your application on.
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Thanks a lot all of you for all the help. I think i will go with Leo. I will not implement the Timeout period but will allow for such changes easily maybe through an interface.
Thanks a lot guys!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: URLyBird Locking Queries