Package lombok

Annotation Type Locked


@Target(METHOD) @Retention(SOURCE) public @interface Locked
Guards all statements in an annotation method with a Lock.

For non-static methods, a field named $lock is used, and for static methods, $LOCK is used. These will be generated if needed and if they aren't already present.

Because Locked uses a different type of lock from Locked.Read and Locked.Write, using both in the same class using the default names will result in a compile time error.

Complete documentation is found at the project lombok features page for @Locked.

  • Element Details

    • value

      String value
      Optional: specify the name of a different field to lock on. It is a compile time error if this field doesn't already exist (the fields are automatically generated only if you don't specify a specific name).
      Returns:
      Name of the field to lock on (blank = generate one).
      Default:
      ""