Re: Is saxbuilder safe for multi-threaded (concurrent) use?

Rolf Lear <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
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 <[email protected]>
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/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.