• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lock / Unlock Overview  RSS feed

Stuart Bell
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,
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!