com.kuka.common.concurrent
Class ConcurrentUtil

java.lang.Object
  extended by com.kuka.common.concurrent.ConcurrentUtil

public final class ConcurrentUtil
extends Object

Utility class for concurrency related methods.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Method Summary
static
<T> boolean
isEqualAndSet(AtomicReference<T> ref, T expect, T update)
          Atomically checks the object in the AtmomicReference for equality with the expected value and updates it with the given value, if equality is given.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEqualAndSet

public static <T> boolean isEqualAndSet(AtomicReference<T> ref,
                                        T expect,
                                        T update)
Atomically checks the object in the AtmomicReference for equality with the expected value and updates it with the given value, if equality is given. The Object.equals(Object) method is used for comparison.

Type Parameters:
T - the type of the reference
Parameters:
ref - the AtomicReference
expect - the expected value
update - the new value
Returns:
true if the value was successfully set. False if the reference value was not equal to the expected value.
See Also:
AtomicReference.compareAndSet(Object, Object)


Copyright © 2019. All rights reserved.