• 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

locking issue

 
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have the following problem. My instructions say, that I'm required to implement (among the others) a lock method, which can look like this.

// Locks a record so that it can only be updated or deleted by this client.
// bla bla bla...
public long lock(int recNo) { }

How is it possible to do it with this argument? I would like to add clientId as a second argument, but this will violate the contract. I implemented my service as a singleton, so I cannot have multiple instances for each client (this would be hard to maintain). How would you conform that requirement without making a spaghetti architecture?
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need a clientId. Use synchronized/wait/notify instead. Java helps us to supply multiply threads. I am "very happy" that I don't have to handle additional clientId's; keep it simple

Hope that helped.

Best Regards,
R
 
Pavel Kubal
Ranch Hand
Posts: 360
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, good idea.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic