Class Counter


  • public abstract class Counter
    extends Object
    Simple counter class
    • Constructor Detail

      • Counter

        public Counter()
    • Method Detail

      • addAndGet

        public abstract long addAndGet​(long delta)
        Adds the given delta to the counters current value
        Parameters:
        delta - the delta to add
        Returns:
        the counters updated value
      • get

        public abstract long get()
        Returns the counters current value
        Returns:
        the counters current value
      • newCounter

        public static Counter newCounter()
        Returns a new counter. The returned counter is not thread-safe.
      • newCounter

        public static Counter newCounter​(boolean threadSafe)
        Returns a new counter.
        Parameters:
        threadSafe - true if the returned counter can be used by multiple threads concurrently.
        Returns:
        a new counter.