Hi all,
Thanks for caring my problem. I have finished my LockManager, can you give me some advices on it. In Data' lock, I call lock in LockManager. And in Data's unlock, I call unlock in LockManager. Before showing the code, see following instructions:
1. I add a HashMap type var lockThreadMap to LockManager. If a record has never been locked, then the first locker thread will be put into lockThreadMap with the recNo as key.
2. In lock, if a record not yet locked, then nothing special. If a record already locked, then get the thread from lockThreadMap with the key recNo and wait on that thread.
3. In unlock, after lockMap remove the lockCookie via key recNo, I fetch recNo corresponded thread from lockThreadMap and call that thread's notify.
Appendix: the LockManager
<Big code portion removed - see below>
I am hoping your replies.
[ April 18, 2006: Message edited by: Barry Gaunt ]
Thanks for caring my problem. I have finished my LockManager, can you give me some advices on it. In Data' lock, I call lock in LockManager. And in Data's unlock, I call unlock in LockManager. Before showing the code, see following instructions:
1. I add a HashMap type var lockThreadMap to LockManager. If a record has never been locked, then the first locker thread will be put into lockThreadMap with the recNo as key.
2. In lock, if a record not yet locked, then nothing special. If a record already locked, then get the thread from lockThreadMap with the key recNo and wait on that thread.
3. In unlock, after lockMap remove the lockCookie via key recNo, I fetch recNo corresponded thread from lockThreadMap and call that thread's notify.
Appendix: the LockManager
<Big code portion removed - see below>
I am hoping your replies.
[ April 18, 2006: Message edited by: Barry Gaunt ]