File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Is SAXParser in JDK6 thread-safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is SAXParser in JDK6 thread-safe?" Watch "Is SAXParser in JDK6 thread-safe?" New topic

Is SAXParser in JDK6 thread-safe?

J Rosetto

Joined: Jun 03, 2008
Posts: 21
Can anyone tell me if the SAXParser in JDK 6 is thread-safe or not?

In my application I want to have a single SAXParser (configured to use a predefined set of schemas), and have several threads use it for parsing their XML.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Since an SAX parser has to keep track of state and can only be attached to one input source, a single instance is NOT thread-safe.

Perhaps you were thinking of using a single instance of SAXParserFactory since it is the factory that gets configured with a schema, etc.

I agree. Here's the link:
subject: Is SAXParser in JDK6 thread-safe?
jQuery in Action, 3rd edition