cc.concurrent.mango.util.concurrent.atomic

类 LongAdder

    • 构造器详细资料

      • LongAdder

        public LongAdder()
        Creates a new adder with initial sum of zero.
    • 方法详细资料

      • add

        public void add(long x)
        Adds the given value.
        指定者:
        add 在接口中 LongAddable
        参数:
        x - the value to add
      • increment

        public void increment()
        Equivalent to add(1).
        指定者:
        increment 在接口中 LongAddable
      • decrement

        public void decrement()
        Equivalent to add(-1).
      • sum

        public long sum()
        Returns the current sum. The returned value is NOT an atomic snapshot: Invocation in the absence of concurrent updates returns an accurate result, but concurrent updates that occur while the sum is being calculated might not be incorporated.
        指定者:
        sum 在接口中 LongAddable
        返回:
        the sum
      • reset

        public void reset()
        Resets variables maintaining the sum to zero. This method may be a useful alternative to creating a new adder, but is only effective if there are no concurrent updates. Because this method is intrinsically racy, it should only be used when it is known that no threads are concurrently updating.
      • sumThenReset

        public long sumThenReset()
        Equivalent in effect to sum() followed by reset(). This method may apply for example during quiescent points between multithreaded computations. If there are updates concurrent with this method, the returned value is not guaranteed to be the final value occurring before the reset.
        返回:
        the sum
      • toString

        public String toString()
        Returns the String representation of the sum().
        覆盖:
        toString 在类中 Object
        返回:
        the String representation of the sum()
      • longValue

        public long longValue()
        Equivalent to sum().
        指定者:
        longValue 在类中 Number
        返回:
        the sum
      • intValue

        public int intValue()
        Returns the sum() as an int after a narrowing primitive conversion.
        指定者:
        intValue 在类中 Number
      • floatValue

        public float floatValue()
        Returns the sum() as a float after a widening primitive conversion.
        指定者:
        floatValue 在类中 Number
      • doubleValue

        public double doubleValue()
        Returns the sum() as a double after a widening primitive conversion.
        指定者:
        doubleValue 在类中 Number

Copyright © 2014. All rights reserved.