Package lombok

Annotation Type Synchronized


@Target(METHOD) @Retention(SOURCE) public @interface Synchronized
Almost exactly like putting the 'synchronized' keyword on a method, except will synchronize on a private internal Object, so that other code not under your control doesn't meddle with your thread management by locking on your own instance.

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. The contents of the fields will be serializable.

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

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Optional: specify the name of a different field to lock on.
  • 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:
      ""