• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server side locking

 
Anurag Mishra
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Guys,
My lock and unlock methods are designed like this
public void lock(int record) throws IOException {
synchronized(lockVector) {
while(lockVector.contains(new Integer(record))||(lockVector.contains(new Integer(-1)))){
try{
lockVector.wait();
}catch(InterruptedException e){
throw new IOException("lock failed");
}
}
lockVector.add(new Integer(record));
}
}
public void unlock(int record) {
synchronized(lockVector){
if(lockVector.contains(new Integer(record))){
lockVector.remove(new Integer(record));
}
lockVector.notifyAll();
}
}
But I have to use these methods in a seperate class called LockManager which resides on server so that locking should be performed on server side, but I am very much confused on these two points:-
1) Firstly, how to use these two methods in a seperate class called LockManager.And if I am using the lock and unlock method on the server side than according to specification i am not using these public method on the client, so is this becomes wrong. Plz help me out, How i should use these method in a seperate file called LockManager.

2) Secondly, how to perform lock from the client side, or in other words how the requested record will be locked, so that appropriate modification can be done.

Anurag Mishra
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic