[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    Re: Trouble with commons-math
From:       "Rahul Akolkar" <rahul.akolkar () gmail ! com>
Date:       2007-10-31 14:28:57
Message-ID: ce1f2ea80710310728o2f451c26m3f89dfc0f2a62d3e () mail ! gmail ! com
[Download RAW message or body]

On 10/31/07, sebb <sebbaz@gmail.com> wrote:
> On 31/10/2007, Brent Worden <brent.worden@gmail.com> wrote:
> > David,
> > 
> > I just checked in a SynchronizedDescriptiveStatistics class that
> > should eliminate the threading issues you're experiencing.  Feel free
> > to grab it out of source control and give it a try.
> > 
> > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/stat/descriptive/SynchronizedDescriptiveStatistics.java?view=markup
> >  
> > 
> > Other interested [math] parties,
> > 
> > To insure I didn't miss anything in my implementation, feel free to
> > look over this latest addition and critique it.
> 
> There are some spelling mistakes in the class description ;-)
> 
> It might be useful to add the annotation @ThreadSafe to the class,
> e.g. as a comment:
> 
> /* @ThreadSafe */
> public class ...
> 
> However, I'm not sure that the class is thread-safe.
> For example the windowSize field is not final, and therefore may not
> be visible to all threads after construction. Making it final would
> fix this.
> 
> Fixing the eDA field might be tricky.
> 
<snip/>

Additionally, suggest couple of smallish changes:

 * r590566 [ http://svn.apache.org/viewvc?rev=590566&view=rev ]

Missing svn props (most importantly, svn:eol-style)

 * r590564 [ http://svn.apache.org/viewvc?rev=590564&view=rev ]

Modified: commons/proper/math/trunk/xdocs/userguide/stat.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/xdocs/userguide/stat.xml?rev=590564&r1=590563&r2=590564&view=diff
 ==============================================================================
--- commons/proper/math/trunk/xdocs/userguide/stat.xml (original)
+++ commons/proper/math/trunk/xdocs/userguide/stat.xml Tue Oct 30 22:38:58 2007
@@ -199,7 +199,16 @@
 }
 in.close();
        </source>
-        </dd>
+        </dd>
+        <dt>Compute statistics in a thread-safe manner</dt>
+        <br/>
+        <dd>Use a <code>ThreadSafeDescriptiveStatistics</code> instance
+        <source>
<snip/>

Line above should say SynchronizedDescriptiveStatistics.


+// Create a SynchronizedDescriptiveStatistics instance and
+// use as any other DescriptiveStatistics instance
+DescriptiveStatistics stats =
DescriptiveStatistics.newInstance(SynchronizedDescriptiveStatistics.class);
+        </source>
+        </dd>
        </dl>
       </p>
      </subsection>




> > Thanks,
> > 
> > Brent.
> > 
> > On Oct 28, 2007 3:42 AM, Torsten Curdt <tcurdt@apache.org> wrote:
> > > Sounds like a threading issue. I'd assume DescriptiveStatistics is
> > > not thread-safe and in your stacktrace I see
> > > 
> > > > at no.mypackage.spring.utils.ExecutionTimeAdviceTest$1.run
> > > > (ExecutionTimeAdviceTest.java:47)
> > > > at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run
> > > > (Unknown Source)
> > > > at java.lang.Thread.run(Thread.java:479)
> > > 
> > > Try to synchronize access to the DescriptiveStatistics
> > > 
> > > cheers
> > > --
> > > Torsten
> > > 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic