This is not an answer, but a talking point about whether this is on, or off topic
---- Version 1 ----
What is the best practice regarding synchronization?
I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help. What are the best practices for making my code thread-safe?
public class Foo {
private String foo = "Foo";
public void setFoo(String newfoo) {
this.foo = newfoo;
}
public String getFoo() {
return foo;
}
}
javasynchronizationbest-practice
---- Version 2 ----
What is the best practice regarding synchronization?
I have this class that works really well, but I need to make my application multi-threaded. I have read that synchronization can help, so I have synchronized the setters.
What are the best practices for making my code thread-safe?
public class Foo {
private String foo = "Foo";
public synchronized void setFoo(String newfoo) {
this.foo = newfoo;
}
public String getFoo() {
return foo;
}
}