Annotations

Learn the use of various annotations used in concurrent code.

If you are interviewing, consider buying our number#1 course for Java Multithreading Interviews.

Overview

In this lesson, we’ll explore the various Java annotations that are related to concurrency. These are:

  1. @ThreadSafe
  2. @NotThreadSafe
  3. @Immutable
  4. @GuardedBy(lock)

Class-level annotations

Note that these annotations serve as documentation about class behavior but don’t change the ability or functionality of class in any way. Also, these class-level annotations become part of the public documentation of a class.

@ThreadSafe

The annotation ...