I'm in final touch to the project. I don't know whether I misunderstood the locking concept. My lock method will lock whole database, so other thread has to wait till the thread which has locked the database release it.
My design is if thread A locked record 5, no other thread can lock any other record.
I think I've to implement like this:
If Thread A locked record 5, all other threads are allowed to lock any record other than record 5.
You need to provide logical record level locking granularity so multiple clients can access your database concurrently
and at the same time (Client A locking record 5, Client B locking record 10 and so on).
In my honest opinion, with that approach locking the entire database, you are serializing all the access to the database
and most likely you will fail or get a very, very low grade as far as the locking requirements go.
And if a similar output is not possible with your current code, I think you'll fail because your locking mechanism is not according to the instructions. And also imagine a mix of reads and finds interfering with this scenario (so between locking of rec4 and rec5 other clients can read rec10, create rec341, find all records in Paris,...)