• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

lock an unlock

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Look! It's Leonardo da Vinci! And he brought a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic