Search in sources :

Example 11 with DoubleAdder

use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.

the class DoubleAdderTest method testReset.

/**
 * reset() causes subsequent sum() to return zero
 */
public void testReset() {
    DoubleAdder ai = new DoubleAdder();
    ai.add(2.0);
    assertEquals(2.0, ai.sum());
    ai.reset();
    assertEquals(0.0, ai.sum());
}
Also used : DoubleAdder(java8.util.concurrent.atomic.DoubleAdder)

Example 12 with DoubleAdder

use of java8.util.concurrent.atomic.DoubleAdder in project streamsupport by stefan-zobel.

the class DoubleAdderTest method testLongValue.

/**
 * longValue returns current value.
 */
public void testLongValue() {
    DoubleAdder ai = new DoubleAdder();
    assertEquals(0, ai.longValue());
    ai.add(1.0);
    assertEquals(1, ai.longValue());
}
Also used : DoubleAdder(java8.util.concurrent.atomic.DoubleAdder)

Aggregations

DoubleAdder (java8.util.concurrent.atomic.DoubleAdder)12 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 ExecutorService (java.util.concurrent.ExecutorService)1 Phaser (java8.util.concurrent.Phaser)1