Author: psteitz Date: Sat Jun 20 21:35:32 2009 New Revision: 786911 URL: http://svn.apache.org/viewvc?rev=786911&view=rev Log: Made aggregation threadsafe.
Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java?rev=786911&r1=786910&r2=786911&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java Sat Jun 20 21:35:32 2009 @@ -49,12 +49,12 @@ * A SummaryStatistics serving as a prototype for creating SummaryStatistics * contributing to this aggregate */ - private SummaryStatistics statisticsPrototype; + private final SummaryStatistics statisticsPrototype; /** * The SummaryStatistics in which aggregate statistics are accumulated */ - private SummaryStatistics statistics; + private final SummaryStatistics statistics; /** * Initializes a new AggregateSummaryStatistics with default statistics @@ -216,7 +216,7 @@ * An additional SummaryStatistics into which values added to these * statistics (and possibly others) are aggregated */ - private SummaryStatistics aggregateStatistics; + private final SummaryStatistics aggregateStatistics; /** * Initializes a new AggregatingSummaryStatistics with the specified @@ -238,7 +238,9 @@ @Override public void addValue(double value) { super.addValue(value); - aggregateStatistics.addValue(value); + synchronized (aggregateStatistics) { + aggregateStatistics.addValue(value); + } } } }