...
Wiki Markup |
---|
While client-side locking is acceptable if the thread-safe class commits to its locking strategy and clearly documents it, Goetz cautions against its misuse \[[Goetz 06|AA. Java References#Goetz 06]\] : |
If extending a class to add another atomic operation is fragile because it distributes the locking code for a class over multiple classes in an object hierarchy, client-side locking is even more fragile because it entails putting locking code for class C into classes that are totally unrelated to C. Exercise care when using client-side locking on classes that do not commit to their locking strategy.
...