Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
This vulnerability can be prevented using a  {{java.lang.Object}} declared {{private}} and {{final}} within the class. The object must be used explicitly for locking purposes in {{synchronized}} blocks within the class’s methods. This intrinsic lock is associated with the instance of the private object and not the class. Consequently, there is no lock contention between this class’s methods and the methods of a hostile class. Bloch refers to this technique as the “private lock object” idiom \[[Bloch 012001|AA. Java References#Bloch 01]\].

...

References

Wiki Markup
\[[Bloch 012001|AA. Java References#Bloch 01]\] Item 52: "Document Thread Safety"

...