----------------------------------
As to your first point, lock is synchronized, when a client calls lock it either locks the record but putting the record number into the HashSet. If another client has the lock, (That record number already exists in the HashSet), then you call wait(), by calling wait,
you allow another thread to call lock() which might be requesting a lock on a different record, that is not in the HashSet, therefore that second client gets the lock for a different record.
Mark.
---------------------------------
Hi Mark,
Thanks for you response. What I have learned is that
lock() is nothing but (syn. {check the record_no in the HashSet + if not found, put record_no in Hashset + read record + modify record + write record}). If request by another thread for the same record comes, that thread will execute wait(). (is this for to save processor resources?).
Hear is my problem,
If request from another thread for diff. record comes, I think, same object can't execute request simultaneously. Because lock() process is syn. and it can't serve multiple thread. Even for diff. record no. But this is not record level locking, so I am not correct.
Mark you patience can help me to pass the exam. Pls. correct me where I am wrong.
Thanks.
Regards,
Sanjeev