本文整理汇总了Java中java.util.concurrent.atomic.AtomicLongArray.setRelease方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicLongArray.setRelease方法的具体用法?Java AtomicLongArray.setRelease怎么用?Java AtomicLongArray.setRelease使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.atomic.AtomicLongArray
的用法示例。
在下文中一共展示了AtomicLongArray.setRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testIndexing
import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/**
* get and set for out of bound indices throw IndexOutOfBoundsException
*/
public void testIndexing() {
AtomicLongArray aa = new AtomicLongArray(SIZE);
for (int index : new int[] { -1, SIZE }) {
final int j = index;
final Runnable[] tasks = {
() -> aa.getPlain(j),
() -> aa.getOpaque(j),
() -> aa.getAcquire(j),
() -> aa.setPlain(j, 1),
() -> aa.setOpaque(j, 1),
() -> aa.setRelease(j, 1),
() -> aa.compareAndExchange(j, 1, 2),
() -> aa.compareAndExchangeAcquire(j, 1, 2),
() -> aa.compareAndExchangeRelease(j, 1, 2),
() -> aa.weakCompareAndSetPlain(j, 1, 2),
() -> aa.weakCompareAndSetVolatile(j, 1, 2),
() -> aa.weakCompareAndSetAcquire(j, 1, 2),
() -> aa.weakCompareAndSetRelease(j, 1, 2),
};
assertThrows(IndexOutOfBoundsException.class, tasks);
}
}
示例2: testGetSetRelease
import java.util.concurrent.atomic.AtomicLongArray; //导入方法依赖的package包/类
/**
* get returns the last value setRelease
*/
public void testGetSetRelease() {
AtomicLongArray aa = new AtomicLongArray(SIZE);
for (int i = 0; i < SIZE; i++) {
aa.setRelease(i, 1);
assertEquals(1, aa.get(i));
aa.setRelease(i, 2);
assertEquals(2, aa.get(i));
aa.setRelease(i, -3);
assertEquals(-3, aa.get(i));
}
}