当前位置: 首页>>代码示例>>Java>>正文


Java AtomicIntegerArray.set方法代码示例

本文整理汇总了Java中java.util.concurrent.atomic.AtomicIntegerArray.set方法的典型用法代码示例。如果您正苦于以下问题:Java AtomicIntegerArray.set方法的具体用法?Java AtomicIntegerArray.set怎么用?Java AtomicIntegerArray.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.atomic.AtomicIntegerArray的用法示例。


在下文中一共展示了AtomicIntegerArray.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIncrementAndGet

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * incrementAndGet increments and returns current value
 */
public void testIncrementAndGet() {
    AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
        aa.set(i, 1);
        assertEquals(2, aa.incrementAndGet(i));
        assertEquals(2, aa.get(i));
        aa.set(i, -2);
        assertEquals(-1, aa.incrementAndGet(i));
        assertEquals(0, aa.incrementAndGet(i));
        assertEquals(1, aa.incrementAndGet(i));
        assertEquals(1, aa.get(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:AtomicIntegerArrayTest.java

示例2: testAddAndGet

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * addAndGet adds given value to current, and returns current value
 */
public void testAddAndGet() {
    AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
        aa.set(i, 1);
        assertEquals(3, aa.addAndGet(i, 2));
        assertEquals(3, aa.get(i));
        assertEquals(-1, aa.addAndGet(i, -4));
        assertEquals(-1, aa.get(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:AtomicIntegerArrayTest.java

示例3: testIntArrayGetAndAccumulate

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * AtomicIntegerArray getAndAccumulate returns previous value and updates
 * with supplied function.
 */
public void testIntArrayGetAndAccumulate() {
    AtomicIntegerArray a = new AtomicIntegerArray(1);
    a.set(0, 1);
    assertEquals(1, a.getAndAccumulate(0, 2, Integer::sum));
    assertEquals(3, a.getAndAccumulate(0, 3, Integer::sum));
    assertEquals(6, a.get(0));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:Atomic8Test.java

示例4: testCompareAndExchangeAcquire

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * compareAndExchangeAcquire succeeds in changing value if equal to
 * expected else fails
 */
public void testCompareAndExchangeAcquire() {
    AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
        aa.set(i, 1);
        assertEquals(1, aa.compareAndExchangeAcquire(i, 1, 2));
        assertEquals(2, aa.compareAndExchangeAcquire(i, 2, -4));
        assertEquals(-4, aa.get(i));
        assertEquals(-4, aa.compareAndExchangeAcquire(i,-5, 7));
        assertEquals(-4, aa.get(i));
        assertEquals(-4, aa.compareAndExchangeAcquire(i, -4, 7));
        assertEquals(7, aa.get(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:AtomicIntegerArray9Test.java

示例5: testGetOpaqueSet

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * getOpaque returns the last value set
 */
public void testGetOpaqueSet() {
    AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
        aa.set(i, 1);
        assertEquals(1, aa.getOpaque(i));
        aa.set(i, 2);
        assertEquals(2, aa.getOpaque(i));
        aa.set(i, -3);
        assertEquals(-3, aa.getOpaque(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:AtomicIntegerArray9Test.java

示例6: testGetPlainSet

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * getPlain returns the last value set
 */
public void testGetPlainSet() {
    AtomicIntegerArray aa = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++) {
        aa.set(i, 1);
        assertEquals(1, aa.getPlain(i));
        aa.set(i, 2);
        assertEquals(2, aa.getPlain(i));
        aa.set(i, -3);
        assertEquals(-3, aa.getPlain(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:AtomicIntegerArray9Test.java

示例7: testSerialization

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
/**
 * a deserialized/reserialized array holds same values in same order
 */
public void testSerialization() throws Exception {
    AtomicIntegerArray x = new AtomicIntegerArray(SIZE);
    for (int i = 0; i < SIZE; i++)
        x.set(i, -i);
    AtomicIntegerArray y = serialClone(x);
    assertNotSame(x, y);
    assertEquals(x.length(), y.length());
    for (int i = 0; i < SIZE; i++) {
        assertEquals(x.get(i), y.get(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:AtomicIntegerArrayTest.java

示例8: test_2ci_neg

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_2ci_neg(AtomicIntegerArray a, AtomicIntegerArray b) {
  for (int i = ARRLEN-1; i >= 0; i-=1) {
    a.set(i, -123);
    b.set(i, -103);
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestIntAtomicVolatile.java

示例9: test_cp_unalndst

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_cp_unalndst(AtomicIntegerArray a, AtomicIntegerArray b) {
  for (int i = 0; i < ARRLEN-UNALIGN_OFF; i+=1) {
    a.set((i+UNALIGN_OFF), b.get(i));
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TestIntAtomicVolatile.java

示例10: test_ci_scl

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_ci_scl(AtomicIntegerArray a, int old) {
  for (int i = 0; i*SCALE < ARRLEN; i+=1) {
    a.set((i*SCALE), -123);
  }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:6,代码来源:TestIntAtomicVolatile.java

示例11: test_2ci_scl

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_2ci_scl(AtomicIntegerArray a, AtomicIntegerArray b) {
  for (int i = 0; i*SCALE < ARRLEN; i+=1) {
    a.set((i*SCALE), -123);
    b.set((i*SCALE), -103);
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestIntAtomicVolatile.java

示例12: test_2vi_scl

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_2vi_scl(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  for (int i = 0; i*SCALE < ARRLEN; i+=1) {
    a.set((i*SCALE), c);
    b.set((i*SCALE), d);
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestIntAtomicVolatile.java

示例13: test_cp_inv

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_cp_inv(AtomicIntegerArray a, AtomicIntegerArray b, int k) {
  for (int i = 0; i < ARRLEN-k; i+=1) {
    a.set((i+k), b.get(i+k));
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:6,代码来源:TestIntAtomicVolatile.java

示例14: test_2ci_aln

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_2ci_aln(AtomicIntegerArray a, AtomicIntegerArray b) {
  for (int i = 0; i < ARRLEN-ALIGN_OFF; i+=1) {
    a.set((i+ALIGN_OFF), -123);
    b.set(i, -103);
  }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:7,代码来源:TestIntAtomicVolatile.java

示例15: test_2vi_off

import java.util.concurrent.atomic.AtomicIntegerArray; //导入方法依赖的package包/类
static void test_2vi_off(AtomicIntegerArray a, AtomicIntegerArray b, int c, int d) {
  for (int i = 0; i < ARRLEN-OFFSET; i+=1) {
    a.set((i+OFFSET), c);
    b.set((i+OFFSET), d);
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestIntAtomicVolatile.java


注:本文中的java.util.concurrent.atomic.AtomicIntegerArray.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。