• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

(B&S)Doubt about my read() concept

 
Saheed Adepoju
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am almost done with my read() method and i came into a position where i had to ask for a little advice on my algorithm! I am using a cache for the contractor records! Suppose i want to read a record i would have to do the following:



Well my question is this:
Am i synchronising too much? Or is just ok! I imagined i check if the record value exist and then i also check it is not locked before i now check for the record!
Again, since i know the number of records in my data file and the instruction says to create a new record we check for the byte flag and can reuse the space of the other record that has a byte flag of 0. Could i hard code:


instead of what i have above?
Please an insight would be appreciated!
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saheed,


sync(reservedRecords){
//wait for the cache if recNo is within the cache
}


Do you mean locked records? Or booked? If booked then it does not belong in the Data class because booking is part of the business logic.

Anyway my personal opinion that it could be just enough to do synchronisation on the actual database file (let the client read the record even when it's locked). This post might be of further assistance to you http://www.coderanch.com/t/187728/java-developer-SCJD/certification/lock-read-or-just-read


Hope it helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic