...
The second, larger, set of concurrency annotations is available from and supported by SureLogic. The SureLogic annotations are released under the The Apache Software License, Version 2.0 and can be downloaded from surelogic.com (jar, javadoc, source). These annotations can be verified by the SureLogic JSure tool and are useful for documenting code even if the tool is unavailable. The SureLogic annotations also include the JCIP annotations because they are supported by the JSure tool (JSure also supports use of the JCIP Jar file).
...
Typically, object construction is considered an exception to the locking policy because objects are thread-confined when they are created. An object is confined to the thread that uses the new
operator to create its instance. After creation, the object can be safely published to other threads. However, the object is not shared until the thread that created the instance allows it to be shared. Safe publication approaches discussed in CON14-J. Do not let the "this" reference escape during object construction can be succinctly expressed with the @Unique("return") annotation.
...
Wiki Markup |
---|
Sutherland and Scherlis \[[Sutherland 10|AA. Java References#Sutherland 10]\] propose annotations that can document thread-confinement policies. Their approach is designed to allow verification of the annotations against code, as it exists. |
For example, to express the design intent that a program has at most one AWT event dispatch thread, several Compute threads, and the Compute threads are forbidden to handle AWT data structures or events, use the following annotations:
...
Wiki Markup |
---|
\[[Bloch 08|AA. Java References#Bloch 08]\] Item 70: "Document thread safety"
\[[Goetz 06|AA. Java References#Goetz 06]\]
\[[Sutherland 10|AA. Java References#Sutherland 10]\] |
...
11. Concurrency (CON) 11. Concurrency (CON) CON02-J. Do not synchronize on objects that may be reused