[Udt-java-commits] SF.net SVN: udt-java:[29] udt-java/trunk/src/main/java/udt/util/ UDTStatistics.j
Status: Alpha
Brought to you by:
bschuller
From: <bsc...@us...> - 2010-04-29 09:27:20
|
Revision: 29 http://udt-java.svn.sourceforge.net/udt-java/?rev=29&view=rev Author: bschuller Date: 2010-04-29 09:27:13 +0000 (Thu, 29 Apr 2010) Log Message: ----------- fix concurrent modification exception Modified Paths: -------------- udt-java/trunk/src/main/java/udt/util/UDTStatistics.java Modified: udt-java/trunk/src/main/java/udt/util/UDTStatistics.java =================================================================== --- udt-java/trunk/src/main/java/udt/util/UDTStatistics.java 2010-04-28 14:51:57 UTC (rev 28) +++ udt-java/trunk/src/main/java/udt/util/UDTStatistics.java 2010-04-29 09:27:13 UTC (rev 29) @@ -199,13 +199,15 @@ * take a snapshot of relevant parameters for later storing to * file using {@link #writeParameterHistory(File)} */ - public synchronized void storeParameters(){ - if(first){ - first=false; - statsHistory.add(new StatisticsHistoryEntry(true,0,"time","packetRate","sendPeriod")); - initialTime=System.currentTimeMillis(); + public void storeParameters(){ + synchronized (statsHistory) { + if(first){ + first=false; + statsHistory.add(new StatisticsHistoryEntry(true,0,"time","packetRate","sendPeriod")); + initialTime=System.currentTimeMillis(); + } + statsHistory.add(new StatisticsHistoryEntry(false,System.currentTimeMillis()-initialTime,packetArrivalRate,sendPeriod)); } - statsHistory.add(new StatisticsHistoryEntry(false,System.currentTimeMillis()-initialTime,packetArrivalRate,sendPeriod)); } /** @@ -215,9 +217,11 @@ public void writeParameterHistory(File toFile)throws IOException{ FileWriter fos=new FileWriter(toFile); try{ - for(StatisticsHistoryEntry s: statsHistory){ - fos.write(s.toString()); - fos.write('\n'); + synchronized (statsHistory) { + for(StatisticsHistoryEntry s: statsHistory){ + fos.write(s.toString()); + fos.write('\n'); + } } }finally{ fos.close(); @@ -234,5 +238,5 @@ } return hexString.toString(); } - + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |