I don't think using a file is a very elegant way of doing this. Personally, I plan on using one of the containers in the Collections API in java.util. I haven't decided yet but am considering HashSet. You could then check to see if your Collection already contained a lock on the requested record and if so you could wait() for the lock to be released. Of course everytime a lock is released, you'll need to notifyAll().
1. if all the methods are syn. then why we need use of HashSet in lock/unlock?
2. in any case, if object is same and all the methods are syn. then operating on single record means blocking all the threads or you can say locking all the db operations.