Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Thread Safe Problem

 
Rishi Yagnik
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!