commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <>
Subject Re: [Math] Synchronization
Date Sat, 21 Jul 2012 18:44:43 GMT
Synchronization in low level code is generally really bad.  This is the
whole point of why Vector was essentially thrown away in Java collections
in favor of ArrayList.

Better to synchronize in the caller who knows about the multi-threading.
 Or simply build a synchronized wrapper in an inner class.

On Sat, Jul 21, 2012 at 6:08 AM, Gilles Sadowski <> wrote:

> >
> > Note that there is a performance price for the synchronization,
> > which may outweigh the benefit of adding it.
> I thought of adding that because one might want to parallelize the
> integration computations while the quadrature rules factory is shared.
> [See e.g. MATH-827, line 41 in the posted code.]
> Without "synchronized", all threads will compute all the rules.
> On my machine (4 cores), in the absence of synchronization, the above test
> indicated that the "computeRule" method was called 18 times!

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message