Class SynchronizedStatistic

  • All Implemented Interfaces:
    Statistic

    public class SynchronizedStatistic
    extends Object
    implements Statistic
    This is a thread-safe wrapper of Statistic by synchronizing all public methods so that only one thread at a time can access the instance. This is essentially the same principle used by Java's synchronized collection class.
    • Method Detail

      • addData

        public void addData​(double... data)
        Description copied from interface: Statistic
        Recompute the statistic with more data, incrementally if possible.
        Specified by:
        addData in interface Statistic
        Parameters:
        data - an array of new items
      • value

        public double value()
        Description copied from interface: Statistic
        Get the value of the statistic.
        Specified by:
        value in interface Statistic
        Returns:
        the statistic
      • N

        public long N()
        Description copied from interface: Statistic
        Get the size of the sample.
        Specified by:
        N in interface Statistic
        Returns:
        the sample size