• 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

Lock / Unlock Overview

Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

This is my first message on this forum so be kind to me
I just started the Developer assignment a couple of days ago and I have resolved the depracated methods. I have now moved onto the lock/unlock methods. Would I be right in saying the following:
- The lock/unlock methods are primarily for locking individual records in the db file.
- I was thinking about using something like a Vector to keep control over which record numbers are locked or not.
- The majority of the other methods in the Data class are synchronized, presumably that is to keep control over the access of the file pointer (so only one thread can have access over the file at one time only).
Couple of questions though:
- Should there be some way to ensure that the Threads obtain a lock first on a record?? What I mean is that Thread A obtains a lock on a record and proceeds to modify, while Thread B could come in and go straight to modifying a record with out a lock?
- Do you have to check that a record is locked in every method that involves writing/reading/deleting to the db file??
- Would it be best to synchronize the lock/unlock method or just have a synchronized block on the container (Vector) that I plan to use for record number storage??

Hope you can add any comments to the above,

Thanks for your time,
What kind of corn soldier are you? And don't say "kernel" - that's only for this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic