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 <
gil...@harfang.homelinux.org> 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!
>

Reply via email to