This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
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

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
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: 13018
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?
It's not a secret anymore!