This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am quite puzzle as to why the given requirement require us to throw RecordNotFoundException in the method lockRecord(long recNo)
I have a hashmap(lockedRecords) which stored the recNo and its matching cookie value.
In the event that a recNo is found in the hashmap, it would mean someone is already using it, and the client wanting to lock the record would need to wait until it is unlocked by the prev client.
In the event that no recNo is found in the lockedRecords, it would mean that the recNo is safe to use for the calling client, and my program would update the hashmap, return the cookie number and notify all.
However, i can't see the occasion where i need to throw a RecordNotFoundException