GuardedBy


  • Cmn
    @Target(allowedTargets = [AnnotationTarget.FIELD, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER])
    @Retention(value = AnnotationRetention.BINARY)
    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 constructors

GuardedBy(value: String)
Cmn

Public properties

String
Cmn

Public constructors

GuardedBy

GuardedBy(value: String)

Public properties

value

val valueString