Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Confused on synchronization of RandomAccessFile

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 ?
It was the best of times. It was the worst of times. It was a tiny ad.
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic