Re: Is saxbuilder safe for multi-threaded (concurrent) use?
Paul Libbrecht <[email protected]>
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Message-ID | <[email protected]> |
That means the best design pattern is to use threadlocals with these or? paul 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 <[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] _______________________________________________ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/[email protected]