• Post Reply Bookmark Topic Watch Topic
  • New Topic

About real synchronized applications

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
I have developed a Teller swing application (modifying user's balance and ...).
in this application, I have a modifyBalance( ) method that modifies user's balance.
in the real world (where there are many tellers), should I declare modifyBalance( ) with the synchronized keyword (to be sure about data integrity)??
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That probably depends on what class modifyBalance() is in. If it's in a Teller class, then synchronizing on the Teller won't help you much - because two different Tellers will still be able to acto concurrently, and that's the problem in this case - you don't want them accessing the Balance simultaneously. But if modifyBalance() is in the Balance class, then synchroning that method will probably help ensure data integrity - because only one synchronized method of a given Balance may run at once, regardless of which Teller is calling the method. It's hard to say more here without more details about the system.
[ February 20, 2004: Message edited by: Jim Yingst ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!