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 raf.seek 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 ?
subject: Confused on synchronization of RandomAccessFile