[jdom-interest] Is saxbuilder safe for multi-threaded (concurrent) use?

Paul Libbrecht paul at hoplahup.net
Tue Nov 8 08:02:08 PST 2011

That means the best design pattern is to use threadlocals with these or?


Le 8 nov. 2011 à 16:44, Rolf Lear a écrit :

> SAXBuilder is *not* thread-safe, but it is reusable....
> i.e. you need one SAXBuilder per thread, but after parsing something, you
> can reuse the builder for the next parse.
> You can run many different SAXBuilders 'in parallel', just so long as no
> specific SAXBuilder instance is referenced from different threads.
> For improved performance set the fast reconfigure and reuseParser flags on
> the builder:
> builder.setReuseParser(true);
> builder.setFastReconfigure(true);
> Rolf
> On Tue, 8 Nov 2011 10:23:06 -0500, cliff palmer <palmercliff at gmail.com>
> wrote:
>> I have a large number (hundreds of thousands) of XML streams embedded in
>> files to examine and was considering a multi-threaded design for the
> java
>> code, dispatching the streams to a number of worker threads that would
> call
>> Saxbuilder.build() then continue with the needed work.  I'm wondering if
>> Saxbuilder.build, and the other JDOM code on which it relies, is "thread
>> safe" so that I don't run into problems with concurrency using it.
>> Obviously my code will have to (also) be concurrency-friendly as well
> and I
>> will have to manage resources carefully.
>> Thanks in advance.
>> Cliff
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

More information about the jdom-interest mailing list