believe you are doing FBNS. Is that correct?
If so, you have changed the lock() method signature to include a RecordNotFoundException - have you specified why you added this in your documentation?
The if statement in the following code appears redundant. Why do you have both an if statement and a while statement that are doing the same check?
However, if we synchronized locker in lock(), even if other thread wanna release their lock, they cannot do so becos it is hold by the current thread. Am I correct?
But T1 will wait at the POINT X, becos, by refering to T2, T2 enters the critical section, so T1 cannot enter into it.
Are you sure your lock() method may throw an IOException ?
Your first call to validateRecord() is useless IMO. Think of the fact that if the record is invalid, nobody will have a lock on it, in such a way that you won't wait for it.
Your second call to validateRecord() should go out of the while loop (just before lockedRecords.add()) : your goal is not to validate the record each time you get a chance to grab the lock, but when you actually can do it.
I see a big issue with the way you get a database lock : let's say that T1 owns a db lock and T2 and T3 are waiting for such a db lock. When T1 will release its db lock, T2 *AND* T3 will be granted the db lock. You should replace the if(dbLockRequest) by a while(dbLockRequest).
Also, you have a requirement that only the client that locks a record may unlock it. How are you handling that? (I suspect that you are handling it the same way I handled it (and therefore I think you are right ) - but I just want to check that you have not forgotten about that requirement).