...
Wiki Markup |
---|
In this case, composition allows the {{CompositeCollection}} class to use its own intrinsic lock in a way that is completely independent of the lock of the underlying list class. This allows the underlying collection to be not thread-safe because the {{CompositeCollection}} wrapper prevents direct access to its methods by publishing its own synchronized equivalents. This approach provides consistent locking even if the underlying class changes its locking policy in the future. \[[Goetz 06|AA. Java References#Goetz 06]\]. |
Risk Assessment
Using client-side locking when the thread-safe class does not commit to its locking strategy can cause data inconsistencies and deadlock.
...