• 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

Thread Safe Problem

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All
I do have a doubt for Thread Safety in my application I am describing my scenerio as follows :
In my application WVSEntry as an Object that used as a javabean which is a dataobject for table row.now in my application consider two operation occurs at time where i need to update that data object(WVSEntry)
My question are as follows :
1)I am updating that object in synchronized method.
2)do i need to synchronized setter and getter method for that WVSEntry Object
I have used SwingUtilities class in my updataion
pls let me know
Rishi
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would make the object itself thread safe. that is, either synchronize the get/set methods (or use synchronized) blocks or make the variables volatile (makes only sense, for immutable variables or primitives, in my opinion).
another way (or some additional thread safety) is to give away copies of the variables or make your object cloneable and use the clone to display the data. when the data has to be changed in the master, you will need thread safety as before.
cheers
c
 
reply
    Bookmark Topic Watch Topic
  • New Topic