Is there any problem with the following code? Someone told me the getter synchronization guard won't work but I don't know why.
Code:public class MyClass {
private volatile JobStatus status = new JobStatus();
protected void setJoblStatus (...) {
synchronized (status) {
status.set(…); //mutating status
}
}
public JobStatus getStatus() {
synchronized (status){
return status;
}
}
}
