Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

GuardedBy

public abstract @interface GuardedBy
implements Annotation

android.support.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

From interface java.lang.annotation.Annotation

Public methods

value

String value ()

Returns
String