This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Why are lock methods required?

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the URLyBird project, the requirements specify an interface that includes
lock(recNo), unlock(recNo), and isLocked(recNo).

The way I'm implementing things, I don't see why the lock methods are required.
Can someone please explain?

First, it looks like only update() and find() are even needed by the
application. Obviously these methods are synchronized so that the file
pointer is not disturbed while seeking/reading/writing. Now, assuming
update() always checks the "owner" field before overwriting, then I've
guaranteed not to overbook on top of another reservation. Therefore, why
is lock needed? My synchronized methods ensure only one update() runs at
a time anyway.

The other problem is that lock() doesn't have a parameter to specify the
client requesting the lock. I can't use thead information here because a
client can connect to any server thread.

Can someone help me, please?

Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are asking for something discussed for million times...
Try to search the forum.
Bras cause cancer. And tiny ads:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic