This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is SAXParser in JDK6 thread-safe?" Watch "Is SAXParser in JDK6 thread-safe?" New topic
Author

Is SAXParser in JDK6 thread-safe?

J Rosetto
Greenhorn

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
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
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.

Bill
 
Consider Paul's rocket mass heater.
 
subject: Is SAXParser in JDK6 thread-safe?