Hi Vince,
Welcome to JavaRanch and this forum.
As you will have noted, I have put your source code between [code] and [/code]
UBB Tags. This ensures that indenting is preserved, making your code easier to read and comment upon. When you create or edit a post there are buttons just below the text window which will help insert the tags for you so that you don't have to remember them.
I have also removed a considerable amount of your code. Please read the JavaRanch
SCJD FAQ, in particular the section titled "What is the policy on posting questions I saw on the exam / details of how to do the assignment?" which explains why posting locking solutions is frowned upon.
Why are you specifying that the lockedRecords collection is final?
This does not really need to be inside your "try" block. The error message used does not match the
test - the test is for the record number being "greater than or equal to zero", not larger than one.
You probably don't want to seek to the recNo - you probably need to calculate the position in the file where that record is located
.
It appears that if your record is deleted, then you will throw a RecordNotFoundException with no other data than the FinalCommonKey.UNEXPECTED constant.
This constant is also used when trying to handle IOExceptions and InterruptedExceptions - you might want to consider chaining exceptions for these. Alternatively you might want to search in this forum to see other ways of handling the IOException since not all methods in Data class throw RecordNotFoundException.
Since you have a collection of locked records in memory, you don't really need to write the locked status to file. In fact I suspect that there is a logic hole here, if one client tried to lock a record at the same time as another was deleting it:
Client A locks record 5Client B attempts to lock record 5 - goes into wait stateClient A deletes record 5Client B locks record 5 In this case client B managed to change the status from deleted to locked
That should give some thoughts to get you started.
Regards, Andrew