Class Atomics
java.lang.Object
com.google.common.util.concurrent.Atomics
Static utility methods pertaining to classes in the
java.util.concurrent.atomic package.- Since:
- 10.0
- Author:
- Kurt Alfred Kluever
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> AtomicReference<@Nullable V> Creates anAtomicReferenceinstance with no initial value.static <V extends @Nullable Object>
AtomicReference<V> newReference(V initialValue) Creates anAtomicReferenceinstance with the given initial value.static <E> AtomicReferenceArray<@Nullable E> newReferenceArray(int length) Creates anAtomicReferenceArrayinstance of given length.static <E extends @Nullable Object>
AtomicReferenceArray<E> newReferenceArray(E[] array) Creates anAtomicReferenceArrayinstance with the same length as, and all elements copied from, the given array.
-
Method Details
-
newReference
@InlineMe(replacement="new AtomicReference<>()", imports="java.util.concurrent.atomic.AtomicReference") public static <V> AtomicReference<@Nullable V> newReference()Creates anAtomicReferenceinstance with no initial value.Note: this method is now unnecessary and should be treated as deprecated. Instead, use the
AtomicReferenceconstructor directly, taking advantage of "diamond" syntax.- Returns:
- a new
AtomicReferencewith no initial value
-
newReference
@InlineMe(replacement="new AtomicReference<>(initialValue)", imports="java.util.concurrent.atomic.AtomicReference") public static <V extends @Nullable Object> AtomicReference<V> newReference(V initialValue) Creates anAtomicReferenceinstance with the given initial value.Note: this method is now unnecessary and should be treated as deprecated. Instead, use the
AtomicReferenceconstructor directly, taking advantage of "diamond" syntax.- Parameters:
initialValue- the initial value- Returns:
- a new
AtomicReferencewith the given initial value
-
newReferenceArray
@InlineMe(replacement="new AtomicReferenceArray<>(length)", imports="java.util.concurrent.atomic.AtomicReferenceArray") public static <E> AtomicReferenceArray<@Nullable E> newReferenceArray(int length) Creates anAtomicReferenceArrayinstance of given length.Note: this method is now unnecessary and should be treated as deprecated. Instead, use the
AtomicReferenceArrayconstructor directly, taking advantage of "diamond" syntax.- Parameters:
length- the length of the array- Returns:
- a new
AtomicReferenceArraywith the given length
-
newReferenceArray
@InlineMe(replacement="new AtomicReferenceArray<>(array)", imports="java.util.concurrent.atomic.AtomicReferenceArray") public static <E extends @Nullable Object> AtomicReferenceArray<E> newReferenceArray(E[] array) Creates anAtomicReferenceArrayinstance with the same length as, and all elements copied from, the given array.Note: this method is now unnecessary and should be treated as deprecated. Instead, use the
AtomicReferenceArrayconstructor directly, taking advantage of "diamond" syntax.- Parameters:
array- the array to copy elements from- Returns:
- a new
AtomicReferenceArraycopied from the given array
-