Andrew,
First of all sorry for posting my code. Thought my failed code would not appeal anybody.
Can IllegalMonitorStateException ever be thrown?
True. I will remove the not needed exceptions.
I don't think a Vector is a good choice
I used Vector because it is synchronized. I would consider changing it to ArrayList.
how are you ensuring that only the client who locks a record can unlock it?
All client calls goes through the interface.
The client does the lock,update,unlock as an atomic operation .
Example
Client A locks the record 5 , as well as the whole collection so no other thread is allowed to lock any record.My lock method synchronizes the whole collection object.
Client A performs the update/delete..etc and calls the unlock which removes the record no from collection and notifies other threads that the collection is unlocked for other threads use.
Client A locks record 5
* Client B starts by unlocking record 5 (don't care if it is locked or not - exception will be swallowed)
* Client B locks record 5
Andrew,
I can sense what you are saying. If i had move my locking completely
to server, then it is going to be a rewrite.
I have documented that all clients should get the lock first before doing update,delete etc.
[ July 15, 2008: Message edited by: John Matman ]