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

lock an unlock

 
wael Hassanin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there a lock and unlock mechanizm when local mode is running..and should i implement a case that local and remote are both running in same time.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wael, you don't need to lock a record in local mode because it is a stand alone program, meaning there will be only one user.
Now on the other hand if you are using multithreading, and the single user can book multiple flights at the same time, even book twice on the same flight at the same time, then some sort of locking could be said to be needed, and could be argued for in your design.txt file.
However, I'd suggest to stay clear of that, it is unneccesary and beyond the requirements.
Mark
 
wael Hassanin
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you very much ..i`ve one more question i`ve a rmidataserver and i implement the lock and unlock there like that :
public void lock(int record, Object obj)
{
//put this object with its record in hashmap and if there is another one wait to notify.
//call lock in class data which just check for record num only if it is correct
}
public void unlock(int record,object obj)
{
//check if this object have a key to unlock in hashmap
}
is this is right or should i keep the signture of lock and unlock as it is in class data
thanx for your help
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't change the signature of the lock and unlock method in the Data class.
Look for threads on LockManager. I think if you follow that solution you will see the best and easiest way to implement locking.
Unfortunately I will be gone for a week, so I can't expound more for you.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic