Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused on synchronization of RandomAccessFile

Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my design, every client use it's own Data class instance. In the Data class, I have a static variable of DataSchema which is singleton and another static variable which type is RandomAccessFile comes from the DataSchema class. This ensures that only one RAF to access the db file at the same time.
I think because I use mutilple Data instance, to define the methods synchronized in Data class isn't make any senses. But some methods in Data must support synchronized mechanism, e.g. read method, there are three steps in it: 1) validate the record whether is valid, if not throws RecordNotFoundException. 2) call method. 3) call DataHelper.readFixedString method to read the data from db file.
If there isn't synchronized mechanism, can make some exceptions, pls see this thread.
What you think about this and what should I do ?
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!