I saw some posts about "clientid"'s role.They said that using of clientid can prevent the case as below: A.lock(27) .. B.unlock(27) A.unlock(27) But I doubted it beacase the sequence of execution is lock-reade-modify-unlock.So if Thread A locked one record suceessfully,then Thread B can't locked the same record.Thread B should blocked in lock() method untill Thread A finish unlock() and notifyAll(). Am I wrong? Please tell me why to use clientid?
Joined: Oct 08, 2001
So if Thread A locked one record suceessfully,then Thread B can't locked the same record.Thread B should blocked in lock() method untill Thread A finish unlock() and notifyAll(). Am I wrong? Please tell me why to use clientid? The problem is not with locking, but with the unlocking. There is an explicit requirement in your instructions (or the javadoc for unlock()) that only the client who locked a particular record can unlock it. The only way to accomplish it is to track the clients. [ June 26, 2003: Message edited by: Eugene Kononov ]
Joined: Jan 30, 2000