JCIP stands for Java
Concurrency in Practice.
It is a book which also
publishes a small library defining 4 annotations:
Last 3 among the above are
meant to annotate classes while the first one is used to annotate
fields and variables. Example:
The above annotation
indicates that the “someVar” must be accessed only when
guarded by “someLock” lock.
Annotating classes and
fields in this manner does not affect the runtime in any way. It
simply helps the users (and also people who maintains the code later)
to understand the behavior of a class/field.
For example, if a class is
annotated ThreadSafe, then its users can have more confidence in
accessing that class with multiple threads.
Another benefit is that
tools like FindBugs can warn against possible use of a class/variable
which violates the annotation.
For example, if a variable
is annotated with GuardedBy annotation, then the tool can warn if
somewhere it’s accessed without a lock.