• 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

Should the criteriaFind be synchronized?

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I implemented the criteriaFind in my RemoteAccess.
Should I make it synchronized?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ray,
That's according to how and where you implemented criteriaFind. In my case it was not necessay because each client had a separate object in which criteriaFind was implemented. If you implemented it in Data or a child and there is only one Data object that is shared by all the clients, then odds are you will need to synchronize it.
Hope this helps,
Michael Morris
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Originally posted by Michel Morris: In my case it was not necessay because each client had a separate object in which criteriaFind was implemented. If you implemented it in Data or a child and there is only one Data object that is shared by all the clients, then odds are you will need to synchronize it.



There are more than one object that access db file at the same time or the search feature is apart of Data object!?
can you talk about!?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alex,


There are more than one object that access db file at the same time or the search feature is apart of Data object!?


The search feature is apart from the Data object in my design. I had a DataSearch interface which had the one method criteriaFind. That was implemented by CriteriaSearch. Each client had its own CriteriaSearch object, so there was no need to synchronize criteriaFind.
Michael Morris
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Ray, but I had to delete the other post you had that was the same question. Duplicate posts you know.
Mark
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
quote:
--------------------------------------------------------------------------------
Originally posted by Michel Morris: In my case it was not necessay because each client had a separate object in which criteriaFind was implemented. If you implemented it in Data or a child and there is only one Data object that is shared by all the clients, then odds are you will need to synchronize it.
--------------------------------------------------------------------------------
why do you need to synchronize it if we are to implement it into the subclass of Data??
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kruger,
You are probably right that there is no need to synch criteriaFind in neither Data nor a subclass. All of the pertinent Data methods that would be involved in criteriaFind are already synchronized. But more importantly, criteriaFind is a non-volatile method from Data's point of view. The only possible problem that I can see is that there is rare possibility of concurrent access to Data's RandomAccessFile since writeRecord is not synchronized. Of course, since it is a private method and all public methods that call it are themselves synchronized, then the only way for that to happen is to add a public unsynchronized method to Data that calls writeRecord.
So I guess I need to backtrack and say, that it is probably unnecessary to synchronize criteriaFind in most designs.
Michael Morris
 
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did synchornize it in my submission because none of the private methods in Data are synchronized. These private methods are used by the criteriaFind method. There is a real possibility for different threads to corrupt the Collection objects used in this method if it is not synchronized. Also I had the method implemented in the Data object and not in a helper class.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic