本文整理汇总了Java中java.util.concurrent.atomic.AtomicReference.getAcquire方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicReference.getAcquire方法的具体用法?Java AtomicReference.getAcquire怎么用?Java AtomicReference.getAcquire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.AtomicReference
的用法示例。
在下文中一共展示了AtomicReference.getAcquire方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addThrowable
import java.util.concurrent.atomic.AtomicReference; //导入方法依赖的package包/类
public static boolean addThrowable(AtomicReference<Throwable> errors, Throwable t) {
for (;;) {
Throwable a = (Throwable) errors.getAcquire();
if (a == TERMINATED) {
return false;
}
Throwable b = CompositeThrowable.combine(a, t);
if (errors.compareAndSet(a, b)) {
return true;
}
}
}
示例2: terminate
import java.util.concurrent.atomic.AtomicReference; //导入方法依赖的package包/类
public static Throwable terminate(AtomicReference<Throwable> errors) {
Throwable a = (Throwable)errors.getAcquire();
if (a != TERMINATED) {
a = (Throwable)errors.getAndSet(TERMINATED);
}
return a;
}
示例3: cancel
import java.util.concurrent.atomic.AtomicReference; //导入方法依赖的package包/类
public static boolean cancel(AtomicReference<Flow.Subscription> field) {
Flow.Subscription a = field.getAcquire();
if (a != CANCELLED) {
a = field.getAndSet(CANCELLED);
if (a != CANCELLED) {
if (a != null) {
a.cancel();
}
return true;
}
}
return false;
}