Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pls give some comments on my lock/unlock

 
stewchicken
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
on server side. by RMI i create and bind only one remoteDataFactoryimpl.it has a method eg create()--which will create Data object for every client which could
get that remoteDataFactoryImpl object by naming lookup.
so relation between client ,remoteDataFactoryImpl and Data object are multi --one--multi,
so we could allow multi client concurrently access database but only allow one client modify record.
but instruction(page 6/10) also requires that if lock method was called with -1,then entire database should be locked..i am confused on this. how to implement on this?
every client has their own Data object now. how to lock enire database for all clients?
belowing is my sample code of lock and unlcok. except lock(-1) funcation ..
static Vector recordContainer =new Vector();
public void lock(int recordnumber){
sychronized(recordContainer){
try{
if(recordContainer.contain(recordnumber))
recordContainer.wait();
else
recordContainer.add(recordnumber);
}catch(Exception e){}
}
}
public void unlock(int recordnumber){
sychronized(recordContainer){
recordContainer.remove(recordnumber);
try{
recordContainer.notifyAll();
}catch(Exception e){}
}
}
public sychronized modify(int recordnumber,DataInfo newData){
lock(recordnumber);
/*
here doing modifying record
*/
unlock(recordnumber);
}
thanks for your attention
 
shailesh sonavadekar
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stewchicken , Welcome to javaranch.
PROPER NAMES ARE NOW REQUIRED
Please look carefully at official naming policy at javaranch & reregister yourself with proper first & last name. Please adhere to official naimg policy & help maintain the decorum of the forum.
Waiting for your posts with proper first & last name. Once you have reregister , please let us know about that & then your previous account will be disabled. if you don't , still it will be disabled.
We would have love to eat stew chicken. But , not here. Here , there is no place for people who come with aliases. I don't understand while people want to have aliases. this is not a private chat room. this is friendly place to share the knowledge. There is no rule so that you have to hide something. Please do the needful.
Regards.

Your Friendly Bartender
Shailesh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic