• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

synchronized RMI Server Methods ???

 
Donald Wedding
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope this isn't a stupid question, I'm just learning RMI.
If I have several Clients calling a Server method which updates the database, does that Server method need to synchronized ?
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RMI is multi-threaded -- it will need to be threadsafe. This may mean that it needs to be synchronized, but that is not necessarily the case.
- Peter
 
Donald Wedding
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter,
So if my RMI methods need to be synchronized, then why did I bother synchronizing my database AND also why did I bother with the record locks?
This looks like it's being repetetive and redundant!
Deja Vu all over again!
Don
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not saying that your RMI methods need to be synchronized. The synchronization in Data may or may not be enough to make them threadsafe. Also, synchronization serves a completely different purpose than database locking. Using sychronization, you are protecting the integrity of your Java objects within the scope of some Java block or method. Using record locks, you are protecting the integrity of your database records within the scope of a business transaction.
- Peter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic