From f4275f337146fd7e2ffe91d4e788c819b5586e88 Mon Sep 17 00:00:00 2001 From: Phil Steitz Date: Sat, 20 Jun 2009 21:35:32 +0000 Subject: [PATCH] Made aggregation threadsafe. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@786911 13f79535-47bb-0310-9956-ffa450edef68 --- .../stat/descriptive/AggregateSummaryStatistics.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java b/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java index 1e79f728a..6c9b899cc 100644 --- a/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java +++ b/src/java/org/apache/commons/math/stat/descriptive/AggregateSummaryStatistics.java @@ -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); + } } } }