Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
    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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

NX: Consideration of synchronize methods in Data class or RAF object

Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
hi, all
My SCJD Assignment is URLyBird. Now I have some questions about my synchronize design.
In my design, I use the singleton design pattern to implement the remote object(RemoteDataImpl class). That means there is only one instance of remote object running on server and every clinet thread can only obtain the same remote object instance. And the RemoteDataImpl class has a static instance of Data class, which implements the DB interface ( provided from Sun Enterprise) and uses a RandomAccessFile object to interact with the database file. Each client's request, such as "Search" and "book", should be actioned through using some business methods of the unique instance of RemoteDataImpl class, which subsequently call some methods of its static instance of Data class.
Originally, I have two choices to implement the synchronize mechanism. One, synchronize all methods of Data class, which are related to database operations. Two, just synchronize the RAF object. However, after carefully analysis, now I have some questions about my design, which ars as follows:
As mentioned above, every clinet thread can only obtain the same remote object instance through RMI. And the remothe object instance has a static instance of Data class. That means each client can access the physical data file only through the same instance of Data class and RAF object. Thus, no matter I chose to synchronize the methods of Data class or RAF object, if there is a client thread which is implmenting a database action, read or write db file, other client threads have to wait untill that client thread ends its action. On another word, suppose now there are 300 client threads connect to RMI server, at a time point, only one client thread can performes its database action, no matter it's a read or write action, all of the left client threads have to wait to obtain the chance.
I think it probably produce performandce problem and server can't respond quickly to client's request. What I want is all the client threads can read db file simultaniously as long as no client thread performe write actions. Of course, if a client is perform write action in db file, all the other clients have to wait.
Could Andrew Monkhouse,Ken Krebs,and Bill Robertson or someone throw your light on my question? Thanks in advance!

author and jackaroo
Posts: 12199
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Robert,
Please don't post the same question more than once. And please allow time for people to read your question and answer it.
I have closed this topic as it is a duplicate of this one
Regards, Andrew
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic