Versions Compared

Key

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

...

Two sets of concurrency annotations are freely available and licensed for use in any code. The first set consists of four annotations described in Java Concurrency in Practice (JCIP) [Goetz 2006a2006], which can be downloaded from jcip.net (jar, javadoc, source). The JCIP annotations are released under the Creative Commons Attribution License.

...

It is important to document all the locks that are being used to protect shared state. According to Brian Goetz and colleagues [Goetz 2006a2006],

For each mutable state variable that may be accessed by more than one thread, all accesses to that variable must be performed with the same lock held. In this case, we say that the variable is guarded by that lock. (p. 28)

...

According to Goetz and colleagues [Goetz 2006a2006],

A state-dependent class should either fully expose (and document) its waiting and notification protocols to subclasses, or prevent subclasses from participating in them at all. (This is an extension of "design and document for inheritance, or else prohibit it" [EJ Item 15].) At the very least, designing a state-dependent class for inheritance requires exposing the condition queues and locks and documenting the condition predicates and synchronization policy; it may also require exposing the underlying state variables. (The worst thing a state-dependent class can do is expose its state to subclasses but not document its protocols for waiting and notification; this is like a class exposing its state variables but not documenting its invariants.) (p. 395)

...

[Bloch 2008]

Item 70, "Document Thread Safety"

[Goetz 2006a2006]

Java Concurrency in Practice

[Sutherland 2010]

Composable Thread Coloring

...