• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Synchronization Granularity

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
From reading the synchronization threads, I�ve seen people sync at many different levels:
1.) Synchronize all public record accessing/modifying methods of their Data class.
2.) Sync on an inner class or member of Data (i.e. a record cache or wrapper obj).
3.) Perform multiple obj sync using a lock map then a single record to update/modify.
However, I haven�t seen an answer to my problem. I was in camp #1, but moved towards #2 (I think the junior programmers can now understand a bit more efficient sync scope ). I�ve modified my record manipulation methods to do something similar to the following:

My concern is now that all �public synchronized� methods have been replaced with just �public�, do I have a synchronization issue with ? The exportRecord method is private to Data, but is not sync�d on anything. I just trust that all record modifying methods call in a sync block that is synchronized on the record cache (which they do since I wrote it that way). So all file I/O is performed in a synchronous manner. My initial unit test for methods that do this sort of thing (delete, update, create, etc.) seem to indicate that it is OK. It should work, but is it acceptable? One new mod/call to update a record outside the sync block and its over. Can someone offer any input? Thanks.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic