Join us on the livestream at Android Dev Summit on 7-8 November 2018, starting at 10AM PDT!

GuardedBy

public abstract @interface GuardedBy
implements Annotation

androidx.annotation.GuardedBy


Denotes that the annotated method or field can only be accessed when holding the referenced lock.

Example:

 final Object objectLock = new Object();

 @GuardedBy("objectLock")
 volatile Object object;

 Object getObject() {
     synchronized (objectLock) {
         if (object == null) {
             object = new Object();
         }
     }
     return object;
 }

Summary

Public methods

String value()

Inherited methods

Public methods

value

public String value ()

Returns
String