File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Confused on synchronization of RandomAccessFile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Confused on synchronization of RandomAccessFile" Watch "Confused on synchronization of RandomAccessFile" New topic

Confused on synchronization of RandomAccessFile

Leo Tien
Ranch Hand

Joined: Sep 10, 2002
Posts: 156
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 ?
I agree. Here's the link:
subject: Confused on synchronization of RandomAccessFile
It's not a secret anymore!