Search in sources :

Example 1 with DoubleAccumulator

use of java.util.concurrent.atomic.DoubleAccumulator in project jdk8u_jdk by JetBrains.

the class Serial method testDoubleAccumulator.

static void testDoubleAccumulator() {
    DoubleBinaryOperator plus = (DoubleBinaryOperator & Serializable) (x, y) -> x + y;
    DoubleAccumulator a = new DoubleAccumulator(plus, 13.9d);
    a.accumulate(17.5d);
    DoubleAccumulator result = echo(a);
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value");
    a.reset();
    result.reset();
    if (result.get() != a.get())
        throw new RuntimeException("Unexpected value after reset");
    checkSerialClassName(a, "java.util.concurrent.atomic.DoubleAccumulator$SerializationProxy");
}
Also used : DoubleBinaryOperator(java.util.function.DoubleBinaryOperator) DoubleAccumulator(java.util.concurrent.atomic.DoubleAccumulator)

Aggregations

DoubleAccumulator (java.util.concurrent.atomic.DoubleAccumulator)1 DoubleBinaryOperator (java.util.function.DoubleBinaryOperator)1