Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronized in local mode

 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Data class is used to access data in Local mode, I am planning to remove all the synchronized key word from method heading in Data class, any comments ?
Thank you
Garandi
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Data class is used to access data in Local mode, I am planning to remove all the synchronized key word from method heading in Data class, any comments ?

I assume that in remote mode, your clients use a remote object that wraps the same instance of Data. If so, the methods of Data must be synchronized to insure thread safety.
Eugene.
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eugene,

I assume that in remote mode, your clients use a remote object that wraps the same instance of Data. If so, the methods of Data must be synchronized to insure thread safety.

Yes, that is what I do.
But what if I remove synchronized from Data and make all my RemotedataServer methods synchronized?
Eugene, I send you a private msg. could you please let me know about it.
Thank you
Garandi
 
John Smith
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

But what if I remove synchronized from Data and make all my RemotedataServer methods synchronized?

But each client has its own RemotedataServer object, right? If so, nothing will prevent client A to call a modify() method of Data while client B is in the middle of it. You need some sort of inter-client (as opposed to intra-client) synchronization, and the common solution here is that remote cients use their own remote objects, but all of these remote objects use the same instance of Data, whose methods are synchronized. This guaranties that although the clients are never aware of each other, they never collide, since there is a semaphore at the crossing, i.e. the synchronized methods of Data.
Eugene.
[ January 15, 2003: Message edited by: Eugene Kononov ]
 
Garandi Garandi
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you it is clear now.
Garandi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic