• 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

About real synchronized applications

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)??
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic