例えば、
public Foo{
private Object mutex = new Object();
private int bar;
public Foo(Foo f){
this.mutex = f.getMutex();
this.bar = f.getBar();
}
public Object getMutex(){
return mutex;
}
public void setBar(int bar){
synchronized(mutex){
this.bar = bar;
}
}
public int getBar(){
synchronized(mutex){
return bar;
}
}
}