据我了解,情况如下:
class Case1{
private Object object;
public synchronized Object getObject() {
return object;
}
public synchronized void setObject(Object object) {
this.object = object;
}
}
与以下相比,将被视为已弃用:
class Case2{
private AtomicReference<Object> object = new AtomicReference<Object>();
public Object getObject() {
return object.get();
}
public void setObject(Object object) {
this.object.set(object);
}
}
我对吗?