In delegation pattern, if I have a concrete class and a wrapper class:
class Wrapper {
Concrete concrete = new Concrete();
void fn() {
concrete.fn();
}
}
class Concrete {
void fn() {
...
}
}
If the method fn()
should be synchronized, then where should I put the synchronized keyword? If we assume Concrete::fn()
will only be called by Wrapper::fn()
, is it true that either place is fine?
Thanks!
Aucun commentaire:
Enregistrer un commentaire