本文整理匯總了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));
}
}