Made aggregation threadsafe.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@786911 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2009-06-20 21:35:32 +00:00
parent aa118ca31c
commit f4275f3371
1 changed files with 6 additions and 4 deletions

View File

@ -49,12 +49,12 @@ public class AggregateSummaryStatistics implements StatisticalSummary,
* 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 @@ public class AggregateSummaryStatistics implements StatisticalSummary,
* 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 @@ public class AggregateSummaryStatistics implements StatisticalSummary,
@Override
public void addValue(double value) {
super.addValue(value);
aggregateStatistics.addValue(value);
synchronized (aggregateStatistics) {
aggregateStatistics.addValue(value);
}
}
}
}