[jdom-interest] Is saxbuilder safe for multi-threaded (concurrent) use?
Rolf Lear
jdom at tuis.net
Tue Nov 8 07:44:25 PST 2011
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
More information about the jdom-interest
mailing list